Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
df23d0cd
Commit
df23d0cd
authored
Dec 23, 2019
by
阮思源
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zyj-exceltozip' into 'master'
导出excel压缩包 See merge request rays/pcloud-book!283
parents
9d19f66b
244d7d6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
10 deletions
+54
-10
GroupTagBizImpl.java
...com/pcloud/book/advertising/biz/impl/GroupTagBizImpl.java
+54
-10
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/advertising/biz/impl/GroupTagBizImpl.java
View file @
df23d0cd
...
@@ -24,6 +24,7 @@ import com.pcloud.book.group.biz.BookGroupClassifyBiz;
...
@@ -24,6 +24,7 @@ import com.pcloud.book.group.biz.BookGroupClassifyBiz;
import
com.pcloud.book.group.dao.BookGroupDao
;
import
com.pcloud.book.group.dao.BookGroupDao
;
import
com.pcloud.book.group.dao.GroupQrcodeDao
;
import
com.pcloud.book.group.dao.GroupQrcodeDao
;
import
com.pcloud.book.group.vo.ClassifyVO
;
import
com.pcloud.book.group.vo.ClassifyVO
;
import
com.pcloud.book.util.common.ThreadPoolUtils
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.biz.MessageBiz
;
import
com.pcloud.common.core.biz.MessageBiz
;
import
com.pcloud.common.core.constant.SystemCode
;
import
com.pcloud.common.core.constant.SystemCode
;
...
@@ -56,8 +57,6 @@ import java.util.Date;
...
@@ -56,8 +57,6 @@ import java.util.Date;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -71,7 +70,6 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -71,7 +70,6 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Slf4j
@Component
(
"groupTagBiz"
)
@Component
(
"groupTagBiz"
)
public
class
GroupTagBizImpl
implements
GroupTagBiz
{
public
class
GroupTagBizImpl
implements
GroupTagBiz
{
private
static
final
ExecutorService
EXECUTOR_SINGLE_SERVICE
=
Executors
.
newSingleThreadExecutor
();
@Autowired
@Autowired
private
GroupQrcodeDao
groupQrcodeDao
;
private
GroupQrcodeDao
groupQrcodeDao
;
...
@@ -282,7 +280,7 @@ public class GroupTagBizImpl implements GroupTagBiz {
...
@@ -282,7 +280,7 @@ public class GroupTagBizImpl implements GroupTagBiz {
}
}
advertisingGroupTagDao
.
insert
(
tagList
);
advertisingGroupTagDao
.
insert
(
tagList
);
//书下每个群添加记录
//书下每个群添加记录
EXECUTOR_SINGLE_SERVICE
.
execute
(()
->
{
ThreadPoolUtils
.
EXPORT_THREAD_POOL
.
execute
(()
->
{
List
<
Long
>
beforeQrcodeIds
=
advertisingGroupTagDao
.
getGroupQrcodeIdsByBrandId
(
brandId
);
List
<
Long
>
beforeQrcodeIds
=
advertisingGroupTagDao
.
getGroupQrcodeIdsByBrandId
(
brandId
);
for
(
Long
bookId
:
bookIds
)
{
for
(
Long
bookId
:
bookIds
)
{
List
<
AdvertisingGroupTag
>
addList
=
new
ArrayList
<>();
List
<
AdvertisingGroupTag
>
addList
=
new
ArrayList
<>();
...
@@ -410,25 +408,71 @@ public class GroupTagBizImpl implements GroupTagBiz {
...
@@ -410,25 +408,71 @@ public class GroupTagBizImpl implements GroupTagBiz {
if
(
ListUtils
.
isEmpty
(
list
))
{
if
(
ListUtils
.
isEmpty
(
list
))
{
return
;
return
;
}
}
EXECUTOR_SINGLE_SERVICE
.
execute
(()
->
{
ThreadPoolUtils
.
EXPORT_THREAD_POOL
.
execute
(()
->
{
String
fileName
=
"微信群导出_"
+
DateUtils
.
getShortDateStr
();
String
fileName
=
"微信群导出"
;
String
zipTitle
=
"微信群导出_"
+
DateUtils
.
getShortDateStr
();
Boolean
isSuccess
=
true
;
Boolean
isSuccess
=
true
;
String
fileUrl
=
""
;
String
fileUrl
=
""
;
try
{
try
{
setGroupInfo
(
list
);
fileUrl
=
packExcelZip4GroupBrand
(
list
,
fileName
,
zipTitle
);
this
.
setGroupMessageInfo
(
list
);
fileUrl
=
exportGroupBrandfile
(
list
,
fileName
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"生成导出文件失败"
+
e
.
getMessage
(),
e
);
log
.
error
(
"生成导出文件失败"
+
e
.
getMessage
(),
e
);
isSuccess
=
false
;
isSuccess
=
false
;
}
}
// 发送消息
// 发送消息
if
(
isSuccess
)
{
if
(
isSuccess
)
{
sendNotify
(
partyId
,
fileUrl
,
fileNam
e
);
sendNotify
(
partyId
,
fileUrl
,
zipTitl
e
);
}
}
});
});
}
}
/**
* excel打包
*/
private
String
packExcelZip4GroupBrand
(
List
<
GroupTagDTO
>
list
,
String
fileName
,
String
zipTitle
)
{
Integer
totalCount
=
list
.
size
();
// 分批Excel文件URL
List
<
String
[]>
fileUrls
=
new
ArrayList
<
String
[]>();
// 每个Excel大小
Integer
perExcelSize
=
10000
;
// 单个excel文件存储
if
(
totalCount
<=
perExcelSize
)
{
setGroupInfo
(
list
);
this
.
setGroupMessageInfo
(
list
);
fileUrls
.
add
(
new
String
[]{
fileName
,
exportGroupBrandfile
(
list
,
fileName
)});
}
// 多个excel文件存储(//大于10000条记录)
else
{
int
excelNums
=
0
;
if
(
totalCount
%
perExcelSize
==
0
)
{
excelNums
=
totalCount
/
perExcelSize
;
}
else
{
excelNums
=
totalCount
/
perExcelSize
+
1
;
}
for
(
int
i
=
0
;
i
<
excelNums
;
i
++)
{
List
<
GroupTagDTO
>
exportList
;
if
(
i
==
excelNums
-
1
)
{
exportList
=
list
.
subList
(
i
*
perExcelSize
,
list
.
size
());
}
else
{
exportList
=
list
.
subList
(
i
*
perExcelSize
,
(
i
+
1
)
*
perExcelSize
);
}
setGroupInfo
(
exportList
);
this
.
setGroupMessageInfo
(
exportList
);
fileUrls
.
add
(
new
String
[]{
fileName
,
exportGroupBrandfile
(
exportList
,
fileName
)});
}
}
// 压缩包url
String
resultUrl
=
null
;
// 压缩文件
if
(!
ListUtils
.
isEmpty
(
fileUrls
))
{
log
.
info
(
"压缩文件fileUrls:"
+
fileUrls
+
"为:"
+
zipTitle
);
UploadResultInfo
uploadResultInfo
=
CompressUtils
.
zip
(
fileUrls
,
zipTitle
);
resultUrl
=
uploadResultInfo
.
getUrl
();
}
return
resultUrl
;
}
/**
/**
* 填充群消息数量
* 填充群消息数量
* @param groupTagDTOS
* @param groupTagDTOS
...
...
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