Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-dj-pe-analysis
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d392f7f1
authored
Dec 25, 2025
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:1047852:导入代码优化
1 parent
005d716f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
rpc-dj-pe-analysis-api/src/main/java/cn/com/glsx/dj/peanalysis/dto/analysis/MerchantProfitRecordImportDTO.java
rpc-dj-pe-analysis/src/main/java/cn/com/glsx/dj/peanalysis/service/BiAnalyseBackgroundService.java
rpc-dj-pe-analysis-api/src/main/java/cn/com/glsx/dj/peanalysis/dto/analysis/MerchantProfitRecordImportDTO.java
View file @
d392f7f
...
@@ -6,7 +6,7 @@ import lombok.Data;
...
@@ -6,7 +6,7 @@ import lombok.Data;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Map
;
import
java.util.
LinkedHash
Map
;
/**
/**
* 门店毛利率导入实体
* 门店毛利率导入实体
...
@@ -24,7 +24,7 @@ public class MerchantProfitRecordImportDTO implements Serializable {
...
@@ -24,7 +24,7 @@ public class MerchantProfitRecordImportDTO implements Serializable {
* 导入数据
* 导入数据
*/
*/
@NotEmpty
(
message
=
"导入数据不能为空"
)
@NotEmpty
(
message
=
"导入数据不能为空"
)
private
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
data
;
private
LinkedHash
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
data
;
/**
/**
* 操作人
* 操作人
...
...
rpc-dj-pe-analysis/src/main/java/cn/com/glsx/dj/peanalysis/service/BiAnalyseBackgroundService.java
View file @
d392f7f
...
@@ -231,7 +231,9 @@ public class BiAnalyseBackgroundService {
...
@@ -231,7 +231,9 @@ public class BiAnalyseBackgroundService {
// 如果有门店名称就要校验门店名称
// 如果有门店名称就要校验门店名称
Map
<
Integer
,
String
>
merchantIdMapName
=
MapUtil
.<
Integer
,
String
>
builder
().
build
();
Map
<
Integer
,
String
>
merchantIdMapName
=
MapUtil
.<
Integer
,
String
>
builder
().
build
();
if
(
values
.
stream
().
anyMatch
(
merchantProfitRecord
->
StrUtil
.
isNotBlank
(
merchantProfitRecord
.
getStoreName
())))
{
if
(
values
.
stream
().
anyMatch
(
merchantProfitRecord
->
StrUtil
.
isNotBlank
(
merchantProfitRecord
.
getStoreName
())))
{
List
<
MerchantNameResponse
>
merchantNameResponses
=
searchMerchantName
(
values
.
stream
().
map
(
ele
->
ele
.
getStoreId
().
intValue
()).
collect
(
Collectors
.
toList
()));
List
<
MerchantNameResponse
>
merchantNameResponses
=
searchMerchantName
(
values
.
stream
()
.
filter
(
ele
->
ObjectUtil
.
isNotNull
(
ele
.
getStoreId
()))
.
map
(
ele
->
ele
.
getStoreId
().
intValue
()).
collect
(
Collectors
.
toList
()));
merchantIdMapName
=
merchantNameResponses
.
stream
().
collect
(
merchantIdMapName
=
merchantNameResponses
.
stream
().
collect
(
Collectors
.
toMap
(
MerchantNameResponse:
:
getMerchantId
,
MerchantNameResponse:
:
getMerchantName
,
(
pre
,
next
)
->
pre
));
Collectors
.
toMap
(
MerchantNameResponse:
:
getMerchantId
,
MerchantNameResponse:
:
getMerchantName
,
(
pre
,
next
)
->
pre
));
}
}
...
@@ -253,6 +255,11 @@ public class BiAnalyseBackgroundService {
...
@@ -253,6 +255,11 @@ public class BiAnalyseBackgroundService {
if
(
CollUtil
.
isEmpty
(
checks
))
{
if
(
CollUtil
.
isEmpty
(
checks
))
{
return
uniqueKeyMapMerchantProfitRecord
;
return
uniqueKeyMapMerchantProfitRecord
;
}
}
// 唯一键不为空的才进行查询
checks
=
checks
.
stream
().
filter
(
ele
->
ObjectUtil
.
isNotNull
(
ele
.
getStoreId
())
&&
StrUtil
.
isNotBlank
(
ele
.
getBusinessType
())
&&
StrUtil
.
isNotBlank
(
ele
.
getMonthYear
()))
.
collect
(
Collectors
.
toList
());
// or 拼接sql不能过长,影响性能同时mysql对sql语句的字节大小存在限制,故需分批查询
// or 拼接sql不能过长,影响性能同时mysql对sql语句的字节大小存在限制,故需分批查询
List
<
MerchantProfitRecord
>
merchantProfitRecords
=
Lists
.
newArrayList
();
List
<
MerchantProfitRecord
>
merchantProfitRecords
=
Lists
.
newArrayList
();
...
@@ -316,20 +323,26 @@ public class BiAnalyseBackgroundService {
...
@@ -316,20 +323,26 @@ public class BiAnalyseBackgroundService {
List
<
String
>
errors
=
Lists
.
newArrayList
();
List
<
String
>
errors
=
Lists
.
newArrayList
();
// 月份校验
// 月份校验
if
(
merchantProfitRecordOperationDTO
.
getMonthYear
().
compareTo
(
nowMonth
)
>
0
)
{
String
monthYear
=
merchantProfitRecordOperationDTO
.
getMonthYear
();
if
(
StrUtil
.
isNotBlank
(
monthYear
))
{
if
(
monthYear
.
compareTo
(
nowMonth
)
>
0
)
{
errors
.
add
(
"无效月份"
);
errors
.
add
(
"无效月份"
);
}
}
}
// 重复校验
// 重复校验
String
uniqueKey
=
StrUtil
.
join
(
SymbolConstants
.
UNDERLINE
,
merchantProfitRecordOperationDTO
.
getStoreId
(),
Long
storeId
=
merchantProfitRecordOperationDTO
.
getStoreId
();
merchantProfitRecordOperationDTO
.
getBusinessType
(),
merchantProfitRecordOperationDTO
.
getMonthYear
());
String
businessType
=
merchantProfitRecordOperationDTO
.
getBusinessType
();
if
(
ObjectUtil
.
isNotNull
(
storeId
)
&&
StrUtil
.
isNotBlank
(
businessType
)
&&
StrUtil
.
isNotBlank
(
monthYear
))
{
String
uniqueKey
=
StrUtil
.
join
(
SymbolConstants
.
UNDERLINE
,
storeId
,
businessType
,
monthYear
);
if
(
uniqueKeyMapMerchantProfitRecord
.
containsKey
(
uniqueKey
))
{
if
(
uniqueKeyMapMerchantProfitRecord
.
containsKey
(
uniqueKey
))
{
errors
.
add
(
"已存在"
);
errors
.
add
(
"已存在"
);
}
}
}
// 无效商户
// 无效商户
String
storeName
=
merchantProfitRecordOperationDTO
.
getStoreName
();
String
storeName
=
merchantProfitRecordOperationDTO
.
getStoreName
();
if
(
StrUtil
.
isNotBlank
(
storeName
))
{
if
(
StrUtil
.
isNotBlank
(
storeName
)
&&
ObjectUtil
.
isNotNull
(
storeId
)
)
{
String
merchantName
=
merchantIdMapName
.
get
(
merchantProfitRecordOperationDTO
.
getStoreId
().
intValue
());
String
merchantName
=
merchantIdMapName
.
get
(
merchantProfitRecordOperationDTO
.
getStoreId
().
intValue
());
if
(
StrUtil
.
isBlank
(
merchantName
)
||
!
StrUtil
.
equalsIgnoreCase
(
merchantName
,
storeName
))
{
if
(
StrUtil
.
isBlank
(
merchantName
)
||
!
StrUtil
.
equalsIgnoreCase
(
merchantName
,
storeName
))
{
errors
.
add
(
"无效商户"
);
errors
.
add
(
"无效商户"
);
...
@@ -418,7 +431,7 @@ public class BiAnalyseBackgroundService {
...
@@ -418,7 +431,7 @@ public class BiAnalyseBackgroundService {
// 获取成功和失败数据
// 获取成功和失败数据
Map
<
Boolean
,
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>>
partitioning
=
data
.
entrySet
().
stream
().
collect
(
Collectors
.
partitioningBy
(
entry
->
Map
<
Boolean
,
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>>
partitioning
=
data
.
entrySet
().
stream
().
collect
(
Collectors
.
partitioningBy
(
entry
->
CollUtil
.
isEmpty
(
entry
.
getValue
().
getErrors
()),
CollUtil
.
isEmpty
(
entry
.
getValue
().
getErrors
()),
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
))
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
,
(
v1
,
v2
)
->
v1
,
()
->
MapUtil
.
newHashMap
(
true
)
))
);
);
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
successData
=
partitioning
.
get
(
true
);
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
successData
=
partitioning
.
get
(
true
);
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
failData
=
partitioning
.
get
(
false
);
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
failData
=
partitioning
.
get
(
false
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment