Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rop-dj-script
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 049d8353
authored
Dec 25, 2025
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:1047852:导入代码优化
1 parent
2a11f9c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
9 deletions
src/main/java/cn/com/glsx/dj/script/listener/excel/MerchantProfitRecordListener.java
src/main/java/cn/com/glsx/dj/script/service/BiAnalyseBackgroundService.java
src/test/java/cn/com/glsx/dj/script/controller/BiAnalyseBackgroundControllerTest.java
src/main/java/cn/com/glsx/dj/script/listener/excel/MerchantProfitRecordListener.java
View file @
049d835
...
...
@@ -85,12 +85,17 @@ public class MerchantProfitRecordListener extends AnalysisEventListener<Merchant
data
.
getErrors
().
addAll
(
errors
);
}
String
uniqueKey
=
StrUtil
.
join
(
SymbolConstants
.
DASH
,
data
.
getStoreId
(),
data
.
getBusinessType
(),
data
.
getMonthYear
());
if
(
parsedUniqueKeys
.
contains
(
uniqueKey
))
{
data
.
getErrors
().
add
(
"重复数据"
);
Long
storeId
=
data
.
getStoreId
();
String
businessType
=
data
.
getBusinessType
();
String
monthYear
=
data
.
getMonthYear
();
if
(
ObjectUtil
.
isNotNull
(
storeId
)
&&
StrUtil
.
isNotBlank
(
businessType
)
&&
StrUtil
.
isNotBlank
(
monthYear
))
{
String
uniqueKey
=
StrUtil
.
join
(
SymbolConstants
.
DASH
,
storeId
,
businessType
,
monthYear
);
if
(
parsedUniqueKeys
.
contains
(
uniqueKey
))
{
data
.
getErrors
().
add
(
"重复数据"
);
}
parsedUniqueKeys
.
add
(
uniqueKey
);
}
parsedUniqueKeys
.
add
(
uniqueKey
);
exportDataMap
.
put
(
context
.
readRowHolder
().
getRowIndex
(),
data
);
}
...
...
src/main/java/cn/com/glsx/dj/script/service/BiAnalyseBackgroundService.java
View file @
049d835
...
...
@@ -213,10 +213,10 @@ public class BiAnalyseBackgroundService {
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
importError
=
MapUtil
.<
Integer
,
MerchantProfitRecordExcelImportDTO
>
builder
().
build
();
// 计算进度条,批量远程调用
List
<
Integer
>
indexList
=
Lists
.
newArrayList
(
readDataMap
.
keySe
t
());
List
<
Integer
>
indexList
=
readDataMap
.
keySet
().
stream
().
sorted
(
Integer:
:
compareTo
).
collect
(
Collectors
.
toLis
t
());
List
<
List
<
Integer
>>
partition
=
ListUtil
.
partition
(
indexList
,
200
);
for
(
List
<
Integer
>
indexes
:
partition
)
{
Map
<
Integer
,
MerchantProfitRecordImportDataDTO
>
batch
=
MapUtil
.<
Integer
,
MerchantProfitRecordImportDataDTO
>
builder
().
build
(
);
LinkedHashMap
<
Integer
,
MerchantProfitRecordImportDataDTO
>
batch
=
new
LinkedHashMap
<>(
indexes
.
size
()
);
for
(
Integer
index
:
indexes
)
{
batch
.
put
(
index
,
merchantProfitRecordConvert
.
merchantProfitRecordExcelDto2Dto
(
readDataMap
.
get
(
index
)));
}
...
...
@@ -328,6 +328,7 @@ public class BiAnalyseBackgroundService {
*/
public
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
readExcelHandler
(
SingleUploadRequest
request
)
{
Map
<
Integer
,
MerchantProfitRecordExcelImportDTO
>
exportDataMap
=
MapUtil
.
newHashMap
(
true
);
try
(
InputStream
inputstream
=
new
BufferedInputStream
(
new
ByteArrayInputStream
(
request
.
getFile
().
getContent
())))
{
EasyExcel
.
read
(
inputstream
,
MerchantProfitRecordExcelImportDTO
.
class
,
new
MerchantProfitRecordListener
(
exportDataMap
))
.
sheet
()
...
...
src/test/java/cn/com/glsx/dj/script/controller/BiAnalyseBackgroundControllerTest.java
View file @
049d835
...
...
@@ -64,9 +64,21 @@ public class BiAnalyseBackgroundControllerTest extends BaseControllerTest {
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<
String
,
String
>();
params
.
add
(
"v"
,
"1.0.0"
);
params
.
add
(
"method"
,
"dj.api.script.merchant.bi.matter.handle"
);
params
.
add
(
"id"
,
"2"
);
params
.
add
(
"handlingStrategy"
,
"giaogiaogiaogiao,hahahaha,nika lufu"
);
params
.
add
(
"sessionId"
,
"6daef60d-58aa-4503-a4b8-d7d55785f452"
);
params
.
add
(
"id"
,
"12"
);
params
.
add
(
"handlingStrategy"
,
"i know, come off it!"
);
params
.
add
(
"sessionId"
,
"174765eb-b6fc-4ad4-ac1b-71d2022cd182"
);
System
.
out
.
println
(
post
(
params
));
}
@Test
public
void
testMerchantBiMatterHandle2
()
throws
Exception
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<
String
,
String
>();
params
.
add
(
"v"
,
"1.0.0"
);
params
.
add
(
"method"
,
"dj.api.script.merchant.bi.matter.handle"
);
params
.
add
(
"id"
,
"12"
);
params
.
add
(
"handlingStrategy"
,
"i know, come off it!"
);
params
.
add
(
"sessionId"
,
"174765eb-b6fc-4ad4-ac1b-71d2022cd182"
);
System
.
out
.
println
(
post
(
params
));
}
...
...
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