Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
spring-simple-operation
Overview
Overview
Details
Activity
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
guokunkun
spring-simple-operation
Commits
3d30f125
Commit
3d30f125
authored
Mar 03, 2026
by
kk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复策划月度统计数据
parent
d7863363
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
9 deletions
+175
-9
A+.xlsx
A+.xlsx
+0
-0
SkuPeopleNameDto.java
...k/spring_simple_operation/model/dto/SkuPeopleNameDto.java
+10
-0
VideoProductMapper.xml
src/main/resources/mapper/VideoProductMapper.xml
+1
-1
MyTest.java
src/test/java/cn/kk/spring_simple_operation/MyTest.java
+164
-8
视频.xlsx
视频.xlsx
+0
-0
No files found.
A+.xlsx
0 → 100644
View file @
3d30f125
File added
src/main/java/cn/kk/spring_simple_operation/model/dto/SkuPeopleNameDto.java
View file @
3d30f125
...
...
@@ -16,4 +16,14 @@ public class SkuPeopleNameDto {
@Excel
(
name
=
"上传人"
)
private
String
peopleName
;
@Excel
(
name
=
"编号"
)
private
String
number
;
@Excel
(
name
=
"正销量增长"
)
private
Integer
positiveSalesGrowth
;
@Excel
(
name
=
"月份"
)
private
String
month
;
}
src/main/resources/mapper/VideoProductMapper.xml
View file @
3d30f125
...
...
@@ -54,7 +54,7 @@
AND vp.video_is_upload_backstage = 1
AND vvp.long_video_url > ''
AND vp2.editor_status = 2
AND vvp.upload_long_video_time BETWEEN 1735660800 AND 17708
00400
AND vvp.upload_long_video_time BETWEEN 1735660800 AND 17708
86799
group by vp.id
</select>
...
...
src/test/java/cn/kk/spring_simple_operation/MyTest.java
View file @
3d30f125
package
cn
.
kk
.
spring_simple_operation
;
import
cn.kk.spring_simple_operation.mapper.PhotoProgressMapper
;
import
cn.kk.spring_simple_operation.mapper.SyncProductPublishMapper
;
import
cn.kk.spring_simple_operation.mapper.VideoProductMapper
;
import
cn.kk.spring_simple_operation.entity.VisualDesigner
;
import
cn.kk.spring_simple_operation.entity.VisualPlanExecutorTaskRecord
;
import
cn.kk.spring_simple_operation.mapper.*
;
import
cn.kk.spring_simple_operation.model.dto.SkuPeopleNameDto
;
import
cn.kk.spring_simple_operation.model.vo.BrandRecordStatisticsVo
;
import
cn.kk.spring_simple_operation.model.vo.PhotoProcessExportVo
;
import
cn.kk.spring_simple_operation.model.vo.VideoProductExportVo
;
import
cn.kk.spring_simple_operation.utils.CommonUtils
;
import
cn.kk.spring_simple_operation.utils.DateUtils
;
import
cn.kk.spring_simple_operation.utils.ExcelUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.junit.jupiter.api.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* @author kk
...
...
@@ -25,15 +35,22 @@ import java.util.List;
@SpringBootTest
public
class
MyTest
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
MyTest
.
class
);
@Resource
private
SyncProductPublishMapper
syncProductPublishMapper
;
private
SyncProductPublishMapper
syncProductPublishMapper
;
@Resource
private
PhotoProgressMapper
photoProgressMapper
;
@Resource
private
VideoProductMapper
videoProductMapper
;
@Resource
private
VisualPlanExecutorTaskRecordMapper
visualPlanExecutorTaskRecordMapper
;
@Resource
private
VisualDesignerMapper
visualDesignerMapper
;
@Test
void
exportVideoProductList
()
{
...
...
@@ -84,4 +101,143 @@ public class MyTest {
util
.
exportExcelFile
(
exports
,
"运营导数据.xlsx"
);
}
@Test
public
void
updatePlanMonthData
()
throws
Exception
{
Set
<
Integer
>
userSet
=
new
HashSet
<>();
userSet
.
add
(
5384
);
userSet
.
add
(
5779
);
userSet
.
add
(
8317
);
Map
<
String
,
Integer
>
userNumberMap
=
visualDesignerMapper
.
selectList
(
Wrappers
.<
VisualDesigner
>
lambdaQuery
()
.
in
(
VisualDesigner:
:
getDepartmentKey
,
"a_plus_plan"
,
"video_plan"
)
.
select
(
VisualDesigner:
:
getVisualNumber
,
VisualDesigner:
:
getUserId
)
).
stream
().
collect
(
Collectors
.
toMap
(
VisualDesigner:
:
getVisualNumber
,
VisualDesigner:
:
getUserId
,
(
a
,
b
)
->
b
));
File
file
=
new
File
(
"A+.xlsx"
);
ExcelUtil
<
SkuPeopleNameDto
>
util
=
new
ExcelUtil
<>(
SkuPeopleNameDto
.
class
);
List
<
SkuPeopleNameDto
>
list
=
util
.
importExcel
(
Files
.
newInputStream
(
file
.
toPath
()));
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
SkuPeopleNameDto:
:
getMonth
))
.
forEach
((
monthCh
,
voList
)
->
{
int
month
=
Integer
.
parseInt
(
monthCh
.
replace
(
"月"
,
""
));
List
<
VisualPlanExecutorTaskRecord
>
visualPlanExecutorTaskRecords
=
visualPlanExecutorTaskRecordMapper
.
selectList
(
Wrappers
.<
VisualPlanExecutorTaskRecord
>
lambdaQuery
()
.
eq
(
VisualPlanExecutorTaskRecord:
:
getYearInt
,
2026
)
.
eq
(
VisualPlanExecutorTaskRecord:
:
getMonthInt
,
month
)
);
if
(
CollectionUtils
.
isEmpty
(
visualPlanExecutorTaskRecords
))
return
;
Map
<
Integer
,
VisualPlanExecutorTaskRecord
>
userMap
=
visualPlanExecutorTaskRecords
.
stream
().
collect
(
Collectors
.
toMap
(
VisualPlanExecutorTaskRecord:
:
getUserId
,
Function
.
identity
()));
for
(
SkuPeopleNameDto
dto
:
voList
)
{
Integer
userId
=
userNumberMap
.
get
(
dto
.
getNumber
());
if
(
CommonUtils
.
isNullOrZero
(
userId
))
{
log
.
error
(
"未找到用户:{}"
,
dto
.
getNumber
());
continue
;
}
VisualPlanExecutorTaskRecord
record
=
userMap
.
get
(
userId
);
if
(
record
!=
null
)
{
record
.
setSalesGrowth
(
dto
.
getPositiveSalesGrowth
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
2026
,
month
,
1
);
Date
time
=
calendar
.
getTime
();
int
appraisingNum
=
visualPlanExecutorTaskRecordMapper
.
getAPlusAppraisingCountByUser
(
DateUtils
.
formatDate
(
time
,
"yyyy-MM"
),
dto
.
getNumber
());
record
.
setAppraisingNum
(
appraisingNum
);
}
}
List
<
VisualPlanExecutorTaskRecord
>
sortList
=
visualPlanExecutorTaskRecords
.
stream
().
filter
(
t
->
!
userSet
.
contains
(
t
.
getUserId
()))
.
sorted
(
Comparator
.
comparingInt
(
VisualPlanExecutorTaskRecord:
:
getSalesGrowth
).
reversed
()).
collect
(
Collectors
.
toList
());
// 设置排名,相同值排名相同,下一位跳过当前排名
int
rank
=
1
;
int
lastSales
=
0
;
for
(
int
i
=
0
;
i
<
sortList
.
size
();
i
++)
{
VisualPlanExecutorTaskRecord
current
=
sortList
.
get
(
i
);
if
(
i
>
0
)
{
// 如果当前值与前一个值不同,则更新排名为当前位置+1
if
(
current
.
getSalesGrowth
()
!=
lastSales
)
{
rank
=
i
+
1
;
// 实现相同值排名相同且下一位跳过排名
}
}
lastSales
=
current
.
getSalesGrowth
();
current
.
setSalesGrowthRank
(
rank
);
}
try
(
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
"a_plus_plan_month_data_"
+
month
+
".sql"
)))
{
for
(
VisualPlanExecutorTaskRecord
record
:
visualPlanExecutorTaskRecords
)
{
writer
.
write
(
String
.
format
(
"update visual_plan_executor_task_record set appraising_num = %d, sales_growth_rank = %d, sales_growth = %d where id = %d;\n"
,
record
.
getAppraisingNum
(),
record
.
getSalesGrowthRank
(),
record
.
getSalesGrowth
(),
record
.
getId
()));
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
});
file
=
new
File
(
"视频.xlsx"
);
util
=
new
ExcelUtil
<>(
SkuPeopleNameDto
.
class
);
list
=
util
.
importExcel
(
Files
.
newInputStream
(
file
.
toPath
()));
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
SkuPeopleNameDto:
:
getMonth
))
.
forEach
((
monthCh
,
voList
)
->
{
int
month
=
Integer
.
parseInt
(
monthCh
.
replace
(
"月"
,
""
));
List
<
VisualPlanExecutorTaskRecord
>
visualPlanExecutorTaskRecords
=
visualPlanExecutorTaskRecordMapper
.
selectList
(
Wrappers
.<
VisualPlanExecutorTaskRecord
>
lambdaQuery
()
.
eq
(
VisualPlanExecutorTaskRecord:
:
getYearInt
,
2026
)
.
eq
(
VisualPlanExecutorTaskRecord:
:
getMonthInt
,
month
)
);
if
(
CollectionUtils
.
isEmpty
(
visualPlanExecutorTaskRecords
))
return
;
Map
<
Integer
,
VisualPlanExecutorTaskRecord
>
userMap
=
visualPlanExecutorTaskRecords
.
stream
().
collect
(
Collectors
.
toMap
(
VisualPlanExecutorTaskRecord:
:
getUserId
,
Function
.
identity
()));
for
(
SkuPeopleNameDto
dto
:
voList
)
{
Integer
userId
=
userNumberMap
.
get
(
dto
.
getNumber
());
if
(
CommonUtils
.
isNullOrZero
(
userId
))
{
log
.
error
(
"未找到用户:{}"
,
dto
.
getNumber
());
continue
;
}
VisualPlanExecutorTaskRecord
record
=
userMap
.
get
(
userId
);
if
(
record
!=
null
)
{
record
.
setSalesGrowth
(
dto
.
getPositiveSalesGrowth
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
2026
,
month
-
1
,
1
);
Date
time
=
calendar
.
getTime
();
Integer
timeSecond
=
DateUtils
.
date2TimeSecond
(
time
);
int
appraisingNum
=
visualPlanExecutorTaskRecordMapper
.
getVideoAppraisingCountByUser
(
DateUtils
.
getStartMonthOffset
(
timeSecond
,
0
),
DateUtils
.
getEndMonthOffset
(
timeSecond
,
0
),
dto
.
getNumber
());
record
.
setAppraisingNum
(
appraisingNum
);
}
}
List
<
VisualPlanExecutorTaskRecord
>
sortList
=
visualPlanExecutorTaskRecords
.
stream
().
filter
(
t
->
!
userSet
.
contains
(
t
.
getUserId
())).
collect
(
Collectors
.
toList
());
// 设置排名,相同值排名相同,下一位跳过当前排名
int
rank
=
1
;
int
lastSales
=
0
;
for
(
int
i
=
0
;
i
<
sortList
.
size
();
i
++)
{
VisualPlanExecutorTaskRecord
current
=
sortList
.
get
(
i
);
if
(
i
>
0
)
{
// 如果当前值与前一个值不同,则更新排名为当前位置+1
if
(
current
.
getSalesGrowth
()
!=
lastSales
)
{
rank
=
i
+
1
;
// 实现相同值排名相同且下一位跳过排名
}
}
lastSales
=
current
.
getSalesGrowth
();
current
.
setSalesGrowthRank
(
rank
);
}
try
(
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
"video_plan_month_data_"
+
month
+
".sql"
)))
{
for
(
VisualPlanExecutorTaskRecord
record
:
visualPlanExecutorTaskRecords
)
{
writer
.
write
(
String
.
format
(
"update visual_plan_executor_task_record set appraising_num = %d, sales_growth_rank = %d, sales_growth = %d where id = %d;\n"
,
record
.
getAppraisingNum
(),
record
.
getSalesGrowthRank
(),
record
.
getSalesGrowth
(),
record
.
getId
()));
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
});
}
}
视频.xlsx
0 → 100644
View file @
3d30f125
File added
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