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
ed52b7be
Commit
ed52b7be
authored
Dec 20, 2018
by
lili
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版权保护导出修改
parent
836d3b34
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
373 additions
and
50 deletions
+373
-50
BookStatusEnum.java
.../main/java/com/pcloud/book/base/enums/BookStatusEnum.java
+29
-0
BookApplication.java
...e-book/src/main/java/com/pcloud/book/BookApplication.java
+0
-4
BookAuthInfoBiz.java
...n/java/com/pcloud/book/copyright/biz/BookAuthInfoBiz.java
+4
-0
BookExportRecordBiz.java
...va/com/pcloud/book/copyright/biz/BookExportRecordBiz.java
+18
-1
BookAuthInfoBizImpl.java
...m/pcloud/book/copyright/biz/impl/BookAuthInfoBizImpl.java
+108
-41
BookExportRecordBizImpl.java
...loud/book/copyright/biz/impl/BookExportRecordBizImpl.java
+20
-0
BookExportRecordDao.java
...va/com/pcloud/book/copyright/dao/BookExportRecordDao.java
+20
-0
BookExportRecordDaoImpl.java
...loud/book/copyright/dao/impl/BookExportRecordDaoImpl.java
+27
-0
BookExportRecord.java
...va/com/pcloud/book/copyright/entity/BookExportRecord.java
+36
-1
BookAuthInfoFacade.java
.../com/pcloud/book/copyright/facade/BookAuthInfoFacade.java
+6
-0
BookAuthInfoFacadeImpl.java
...ud/book/copyright/facade/impl/BookAuthInfoFacadeImpl.java
+9
-0
BookEvent.java
...ook/src/main/java/com/pcloud/book/mq/event/BookEvent.java
+48
-0
BookExportRecord.Mapper.xml
...in/resources/mapper/copyright/BookExportRecord.Mapper.xml
+48
-3
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/base/enums/BookStatusEnum.java
View file @
ed52b7be
...
@@ -109,4 +109,33 @@ public enum BookStatusEnum {
...
@@ -109,4 +109,33 @@ public enum BookStatusEnum {
this
.
value
=
value
;
this
.
value
=
value
;
}
}
}
}
public
enum
BookExportStatus
{
/**
* 进行中
*/
ON
(
0
),
/**
* 已完成
*/
SUCCESS
(
1
),
/**
* 失败
*/
FAIL
(
2
);
public
final
Integer
value
;
/**
* 构造
*
* @param value
*/
BookExportStatus
(
Integer
value
)
{
this
.
value
=
value
;
}
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/BookApplication.java
View file @
ed52b7be
package
com
.
pcloud
.
book
;
package
com
.
pcloud
.
book
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.pcloud.book.copyright.biz.BookAuthOrderBiz
;
import
com.pcloud.book.mq.config.MQTopicConumer
;
import
com.pcloud.book.mq.config.MQTopicConumer
;
import
com.pcloud.common.core.constant.MQTopicProducer
;
import
com.pcloud.common.core.constant.MQTopicProducer
;
import
com.pcloud.common.core.mq.RabbitMQFactory
;
import
com.pcloud.common.core.mq.RabbitMQFactory
;
import
com.pcloud.facade.tradecenter.entity.Genuine
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -14,7 +12,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
...
@@ -14,7 +12,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.feign.EnableFeignClients
;
import
org.springframework.cloud.netflix.feign.EnableFeignClients
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -29,7 +26,6 @@ import springfox.documentation.spring.web.plugins.Docket;
...
@@ -29,7 +26,6 @@ import springfox.documentation.spring.web.plugins.Docket;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
@SpringBootApplication
@SpringBootApplication
...
...
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/BookAuthInfoBiz.java
View file @
ed52b7be
...
@@ -68,4 +68,8 @@ public interface BookAuthInfoBiz {
...
@@ -68,4 +68,8 @@ public interface BookAuthInfoBiz {
* 获取图书授权基本信息
* 获取图书授权基本信息
*/
*/
BookAuthInfoVO
getAuthBookInfo
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
Long
sceneId
);
BookAuthInfoVO
getAuthBookInfo
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
Long
sceneId
);
/**
* 获取是否有正在导出的
*/
Boolean
isHaveExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/BookExportRecordBiz.java
View file @
ed52b7be
...
@@ -9,7 +9,24 @@ import com.pcloud.book.copyright.entity.BookExportRecord;
...
@@ -9,7 +9,24 @@ import com.pcloud.book.copyright.entity.BookExportRecord;
public
interface
BookExportRecordBiz
{
public
interface
BookExportRecordBiz
{
/**
/**
* 新增
到处
记录
* 新增
导出
记录
*/
*/
void
insertRecord
(
BookExportRecord
bookExportRecord
);
void
insertRecord
(
BookExportRecord
bookExportRecord
);
/**
* 更新导出记录
*/
void
updateRecordStatus
(
BookExportRecord
bookExportRecord
);
/**
* 获取是否有正在到处的数据
*/
Boolean
isHaveExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
);
/**
* 更新导出记录
*/
void
updateRecord
(
BookExportRecord
bookExportRecord
);
void
handleExportFail
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/impl/BookAuthInfoBizImpl.java
View file @
ed52b7be
...
@@ -96,6 +96,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
...
@@ -96,6 +96,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
setBookAuthOpen
(
SetAuthOpenParam
setAuthOpenParam
,
Long
adviserId
)
{
public
void
setBookAuthOpen
(
SetAuthOpenParam
setAuthOpenParam
,
Long
adviserId
)
{
checkIsCanExport
(
setAuthOpenParam
,
adviserId
);
BookAuthInfoVO
bookAuthInfoVO
=
bookAuthInfoDao
.
getInfoByBook
(
setAuthOpenParam
.
getBookId
(),
setAuthOpenParam
.
getChannelId
(),
adviserId
);
BookAuthInfoVO
bookAuthInfoVO
=
bookAuthInfoDao
.
getInfoByBook
(
setAuthOpenParam
.
getBookId
(),
setAuthOpenParam
.
getChannelId
(),
adviserId
);
BookAuthInfo
bookAuthInfo
=
new
BookAuthInfo
();
BookAuthInfo
bookAuthInfo
=
new
BookAuthInfo
();
BeanUtils
.
copyProperties
(
setAuthOpenParam
,
bookAuthInfo
);
BeanUtils
.
copyProperties
(
setAuthOpenParam
,
bookAuthInfo
);
...
@@ -121,20 +122,37 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
...
@@ -121,20 +122,37 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
JedisClusterUtils
.
setJson
(
key
,
bookAuth
);
JedisClusterUtils
.
setJson
(
key
,
bookAuth
);
}
}
/**
* 校验是否能导出
*/
private
void
checkIsCanExport
(
SetAuthOpenParam
setAuthOpenParam
,
Long
adviserId
)
{
Integer
codeCount
=
setAuthOpenParam
.
getCodeCount
();
if
(
codeCount
==
null
||
codeCount
==
0
)
{
return
;
}
Boolean
isHaveExport
=
isHaveExport
(
setAuthOpenParam
.
getBookId
(),
setAuthOpenParam
.
getChannelId
(),
adviserId
);
if
(
isHaveExport
)
{
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"您有正在导出的授权码,请不要重复点击导出。导出之后系统会有站内信通知,请留意下右上角的消息中心!"
);
}
}
@ParamLog
(
"异步导出"
)
@ParamLog
(
"异步导出"
)
private
void
asynExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
Integer
codeCount
,
Integer
isHaveBarCode
)
{
private
void
asynExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
Integer
codeCount
,
Integer
isHaveBarCode
)
{
EXECUTOR_SERVICE
.
execute
(()
->
{
EXECUTOR_SERVICE
.
execute
(()
->
{
String
commitTime
=
DateUtils
.
formatDate
(
new
Date
());
String
commitTime
=
DateUtils
.
formatDate
(
new
Date
());
String
num
=
""
;
try
{
try
{
if
(
codeCount
==
null
||
codeCount
==
0
)
{
if
(
codeCount
==
null
||
codeCount
==
0
)
{
return
;
return
;
}
}
//获取批次号
Integer
batchNum
=
bookAuthCodeBiz
.
getMaxBatchNum
(
bookId
,
channelId
,
adviserId
);
num
=
String
.
format
(
"%04d"
,
batchNum
);
//新增导出记录
insertExportRecord
(
bookId
,
channelId
,
adviserId
,
num
);
//获取图书名称
//获取图书名称
BookDto
bookDto
=
bookBiz
.
getBaseById
(
bookId
);
BookDto
bookDto
=
bookBiz
.
getBaseById
(
bookId
);
if
(
bookDto
==
null
)
return
;
if
(
bookDto
==
null
)
return
;
//获取批次号
Integer
batchNum
=
bookAuthCodeBiz
.
getMaxBatchNum
(
bookId
,
channelId
,
adviserId
);
String
num
=
String
.
format
(
"%04d"
,
batchNum
);
//获取随机数
//获取随机数
List
<
String
>
uuids
=
CopyrightTools
.
createShortUuidByCount
(
codeCount
);
List
<
String
>
uuids
=
CopyrightTools
.
createShortUuidByCount
(
codeCount
);
List
<
BookAuthCode
>
bookAuthCodes
=
new
ArrayList
<>();
List
<
BookAuthCode
>
bookAuthCodes
=
new
ArrayList
<>();
...
@@ -162,14 +180,28 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
...
@@ -162,14 +180,28 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
//发送站内信
//发送站内信
sendLetter
(
adviserId
,
bookDto
.
getBookName
(),
noticeUrl
,
commitTime
);
sendLetter
(
adviserId
,
bookDto
.
getBookName
(),
noticeUrl
,
commitTime
);
//新增导出记录
//新增导出记录
insertExport
Record
(
bookId
,
channelId
,
adviserId
,
num
,
noticeUrl
);
updateSuccess
Record
(
bookId
,
channelId
,
adviserId
,
num
,
noticeUrl
);
LOGGER
.
info
(
"url"
+
noticeUrl
);
LOGGER
.
info
(
"url"
+
noticeUrl
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"导出条形码失败"
+
e
.
getMessage
(),
e
);
LOGGER
.
error
(
"导出条形码失败"
+
e
.
getMessage
(),
e
);
updateExportRecord
(
bookId
,
channelId
,
adviserId
,
num
,
BookStatusEnum
.
BookExportStatus
.
FAIL
.
value
);
}
}
});
});
}
}
@ParamLog
(
"设置导出成功记录"
)
private
void
updateSuccessRecord
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
num
,
String
noticeUrl
)
{
BookExportRecord
bookExportRecord
=
new
BookExportRecord
();
bookExportRecord
.
setBookId
(
bookId
);
bookExportRecord
.
setAdviserId
(
adviserId
);
bookExportRecord
.
setChannelId
(
channelId
);
bookExportRecord
.
setLastModifiedUser
(
adviserId
);
bookExportRecord
.
setExportStatus
(
BookStatusEnum
.
BookExportStatus
.
SUCCESS
.
value
);
bookExportRecord
.
setDownloadUrl
(
noticeUrl
);
bookExportRecord
.
setBatchNum
(
num
);
bookExportRecordBiz
.
updateRecord
(
bookExportRecord
);
}
@ParamLog
(
value
=
"生成excel"
,
isBefore
=
false
)
@ParamLog
(
value
=
"生成excel"
,
isBefore
=
false
)
private
String
generateExcel
(
List
<
BookAuthCode
>
bookAuthCodes
,
String
bookName
)
{
private
String
generateExcel
(
List
<
BookAuthCode
>
bookAuthCodes
,
String
bookName
)
{
List
<
Object
[]>
dataList
=
new
ArrayList
<
Object
[]>();
List
<
Object
[]>
dataList
=
new
ArrayList
<
Object
[]>();
...
@@ -192,16 +224,28 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
...
@@ -192,16 +224,28 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
}
@ParamLog
(
"新增导出记录"
)
@ParamLog
(
"新增导出记录"
)
private
void
insertExportRecord
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
batchNum
,
String
url
)
{
private
void
insertExportRecord
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
num
)
{
BookExportRecord
bookExportRecord
=
new
BookExportRecord
();
BookExportRecord
bookExportRecord
=
new
BookExportRecord
();
bookExportRecord
.
setBookId
(
bookId
);
bookExportRecord
.
setBookId
(
bookId
);
bookExportRecord
.
setAdviserId
(
adviserId
);
bookExportRecord
.
setAdviserId
(
adviserId
);
bookExportRecord
.
setChannelId
(
channelId
);
bookExportRecord
.
setChannelId
(
channelId
);
bookExportRecord
.
setBatchNum
(
batchNum
);
bookExportRecord
.
setBatchNum
(
num
);
bookExportRecord
.
setDownloadUrl
(
url
);
bookExportRecordBiz
.
insertRecord
(
bookExportRecord
);
bookExportRecordBiz
.
insertRecord
(
bookExportRecord
);
}
}
@ParamLog
(
"修改导出记录"
)
private
void
updateExportRecord
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
num
,
Integer
exportStatus
)
{
if
(
StringUtil
.
isEmpty
(
num
))
return
;
BookExportRecord
bookExportRecord
=
new
BookExportRecord
();
bookExportRecord
.
setBookId
(
bookId
);
bookExportRecord
.
setAdviserId
(
adviserId
);
bookExportRecord
.
setBatchNum
(
num
);
bookExportRecord
.
setChannelId
(
channelId
);
bookExportRecord
.
setLastModifiedUser
(
adviserId
);
bookExportRecord
.
setExportStatus
(
exportStatus
);
bookExportRecordBiz
.
updateRecordStatus
(
bookExportRecord
);
}
@ParamLog
(
"发送站内信"
)
@ParamLog
(
"发送站内信"
)
private
void
sendLetter
(
Long
adviserId
,
String
bookName
,
String
url
,
String
commitTime
)
{
private
void
sendLetter
(
Long
adviserId
,
String
bookName
,
String
url
,
String
commitTime
)
{
SendNotifyDto
sendNotifyDto
=
new
SendNotifyDto
();
SendNotifyDto
sendNotifyDto
=
new
SendNotifyDto
();
...
@@ -220,48 +264,65 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
...
@@ -220,48 +264,65 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
}
// /**
/* *//**
// * 生成word并打包成zip
* 生成word并打包成zip
// */
*//*
// private String generateWordAndZip(List<BookAuthCode> bookAuthCodes, String fileName) {
private String generateWordAndZip(List<BookAuthCode> bookAuthCodes, String fileName) {
// List<String[]> wordUrls = new ArrayList<>();
List<String[]> wordUrls = new ArrayList<>();
// List<WordPO> wordPOs = Lists.newArrayList();
List<WordPO> wordPOs = Lists.newArrayList();
// 调用导出word
int num = 1;
for (int i = 0; i < bookAuthCodes.size(); i++) {
BookAuthCode bookAuthCode = bookAuthCodes.get(i);
//生成条形码
String code = bookAuthCode.getFullCode();
String codeUrl = CopyrightTools.generateBarCode128Local(code, String.valueOf(0.5), String.valueOf(30));
wordPOs.add(new WordImagePO(OssUtils.urlAddKeyLong(codeUrl),
ParagraphAlignment.LEFT.getValue(), 120, 360, null, " " + code));
if (5000 == num || i == bookAuthCodes.size() - 1) {// 每5000个生成一个word
String outPath = "";
try {
outPath = WordUtils.create2(wordPOs);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
if (StringUtils.isEmpty(outPath)) {
return null;
}
// 将word上传到oss文件服务器上
UploadResultInfo uploadLocalFile = OssUtils.uploadLocalFile(outPath, fileName);
String wordUrl = uploadLocalFile.getUrl();// 删除文件
FileUtils.deleteFolder(outPath);
String[] url = {fileName, wordUrl};
wordUrls.add(url);
wordPOs.clear();
num = 0;
}
num++;
}
UploadResultInfo zipUrlInfo = CompressUtils.zip(wordUrls, fileName);
return zipUrlInfo != null ? zipUrlInfo.getUrl() : null;
}*/
// private String generateZip(List<BookAuthCode> bookAuthCodes, String fileName, String excelUrl) {
// // 调用导出word
// // 调用导出word
// int num = 1;
// List<String[]> picUrls = new ArrayList<>();
// String[] excel = {fileName, excelUrl};
// picUrls.add(excel);
// for (int i = 0; i < bookAuthCodes.size(); i++) {
// for (int i = 0; i < bookAuthCodes.size(); i++) {
// BookAuthCode bookAuthCode = bookAuthCodes.get(i);
// BookAuthCode bookAuthCode = bookAuthCodes.get(i);
// //生成条形码
// //生成条形码
// String code = bookAuthCode.getFullCode();
// String codeUrl = CopyrightTools.generateBarCode128Local(bookAuthCode.getFullCode(), String.valueOf(0.5), String.valueOf(30));
// String codeUrl = CopyrightTools.generateBarCode128Local(code, String.valueOf(0.5), String.valueOf(30));
// String[] code = {bookAuthCode.getFullCode(), codeUrl};
// wordPOs.add(new WordImagePO(OssUtils.urlAddKeyLong(codeUrl),
// picUrls.add(code);
// ParagraphAlignment.LEFT.getValue(), 120, 360, null, " " + code));
// if (5000 == num || i == bookAuthCodes.size() - 1) {// 每5000个生成一个word
// String outPath = "";
// try {
// outPath = WordUtils.create2(wordPOs);
// } catch (Exception e) {
// LOGGER.error(e.getMessage(), e);
// }
// if (StringUtils.isEmpty(outPath)) {
// return null;
// }
// // 将word上传到oss文件服务器上
// UploadResultInfo uploadLocalFile = OssUtils.uploadLocalFile(outPath, fileName);
// String wordUrl = uploadLocalFile.getUrl();
// // 删除文件
// FileUtils.deleteFolder(outPath);
// String[] url = {fileName, wordUrl};
// wordUrls.add(url);
// wordPOs.clear();
// num = 0;
// }
// num++;
// }
// }
// UploadResultInfo zipUrlInfo = CompressUtils.zip
(word
Urls, fileName);
// UploadResultInfo zipUrlInfo = CompressUtils.zip
NoSuffix(pic
Urls, fileName);
// return zipUrlInfo != null ? zipUrlInfo.getUrl() : null;
// return zipUrlInfo != null ? zipUrlInfo.getUrl() : null;
//
// }
// }
@Override
@Override
@ParamLog
(
"设置版权保护状态"
)
@ParamLog
(
"设置版权保护状态"
)
public
void
setAuthStatus
(
SetAuthStatusParam
setAuthStatusParam
,
Long
adviserId
)
{
public
void
setAuthStatus
(
SetAuthStatusParam
setAuthStatusParam
,
Long
adviserId
)
{
...
@@ -416,4 +477,10 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
...
@@ -416,4 +477,10 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
BookAuthInfoVO
infoByBook
=
getInfoByBook
(
bookId
,
channelId
,
adviserId
);
BookAuthInfoVO
infoByBook
=
getInfoByBook
(
bookId
,
channelId
,
adviserId
);
return
infoByBook
;
return
infoByBook
;
}
}
@Override
@ParamLog
(
"是否有正在导出的"
)
public
Boolean
isHaveExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
)
{
Boolean
isCanExport
=
bookExportRecordBiz
.
isHaveExport
(
bookId
,
channelId
,
adviserId
);
return
isCanExport
;
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/impl/BookExportRecordBizImpl.java
View file @
ed52b7be
...
@@ -21,4 +21,24 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz {
...
@@ -21,4 +21,24 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz {
public
void
insertRecord
(
BookExportRecord
bookExportRecord
)
{
public
void
insertRecord
(
BookExportRecord
bookExportRecord
)
{
bookExportRecordDao
.
insert
(
bookExportRecord
);
bookExportRecordDao
.
insert
(
bookExportRecord
);
}
}
@Override
public
void
updateRecordStatus
(
BookExportRecord
bookExportRecord
)
{
bookExportRecordDao
.
updateRecordStatus
(
bookExportRecord
);
}
@Override
public
Boolean
isHaveExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
)
{
return
bookExportRecordDao
.
isHaveExport
(
bookId
,
channelId
,
adviserId
);
}
@Override
public
void
updateRecord
(
BookExportRecord
bookExportRecord
)
{
bookExportRecordDao
.
updateRecord
(
bookExportRecord
);
}
@Override
public
void
handleExportFail
()
{
bookExportRecordDao
.
handleExportFail
();
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/dao/BookExportRecordDao.java
View file @
ed52b7be
...
@@ -8,4 +8,24 @@ import com.pcloud.common.core.dao.BaseDao;
...
@@ -8,4 +8,24 @@ import com.pcloud.common.core.dao.BaseDao;
* @date 2018/12/4 19:20
* @date 2018/12/4 19:20
*/
*/
public
interface
BookExportRecordDao
extends
BaseDao
<
BookExportRecord
>
{
public
interface
BookExportRecordDao
extends
BaseDao
<
BookExportRecord
>
{
/**
* 更新导出记录
*/
void
updateRecordStatus
(
BookExportRecord
bookExportRecord
);
/**
* 获取是否有正在导出的数据
*/
Boolean
isHaveExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
);
/**
* 更新导出记录
*/
void
updateRecord
(
BookExportRecord
bookExportRecord
);
/**
* 处理导出
*/
void
handleExportFail
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/dao/impl/BookExportRecordDaoImpl.java
View file @
ed52b7be
...
@@ -5,10 +5,37 @@ import com.pcloud.book.copyright.entity.BookExportRecord;
...
@@ -5,10 +5,37 @@ import com.pcloud.book.copyright.entity.BookExportRecord;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
/**
* @author lily
* @author lily
* @date 2018/12/4 19:20
* @date 2018/12/4 19:20
*/
*/
@Component
(
"bookExportRecordDao"
)
@Component
(
"bookExportRecordDao"
)
public
class
BookExportRecordDaoImpl
extends
BaseDaoImpl
<
BookExportRecord
>
implements
BookExportRecordDao
{
public
class
BookExportRecordDaoImpl
extends
BaseDaoImpl
<
BookExportRecord
>
implements
BookExportRecordDao
{
@Override
public
void
updateRecordStatus
(
BookExportRecord
bookExportRecord
)
{
this
.
getSqlSession
().
update
(
this
.
getStatement
(
"updateRecordStatus"
),
bookExportRecord
);
}
@Override
public
Boolean
isHaveExport
(
Long
bookId
,
Long
channelId
,
Long
adviserId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"bookId"
,
bookId
);
paramMap
.
put
(
"channelId"
,
channelId
);
paramMap
.
put
(
"adviserId"
,
adviserId
);
return
this
.
getSqlSession
().
selectOne
(
this
.
getStatement
(
"isHaveExport"
),
paramMap
);
}
@Override
public
void
updateRecord
(
BookExportRecord
bookExportRecord
)
{
this
.
getSqlSession
().
update
(
this
.
getStatement
(
"updateRecord"
),
bookExportRecord
);
}
@Override
public
void
handleExportFail
()
{
this
.
getSqlSession
().
update
(
this
.
getStatement
(
"handleExportFail"
));
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/entity/BookExportRecord.java
View file @
ed52b7be
...
@@ -33,9 +33,17 @@ public class BookExportRecord extends BaseEntity {
...
@@ -33,9 +33,17 @@ public class BookExportRecord extends BaseEntity {
@ApiModelProperty
(
"创建人"
)
@ApiModelProperty
(
"创建人"
)
private
Long
createdUser
;
private
Long
createdUser
;
@ApiModelProperty
(
"创建时间
不带时分秒
"
)
@ApiModelProperty
(
"创建时间"
)
private
Date
createdDate
;
private
Date
createdDate
;
@ApiModelProperty
(
"最后修改人"
)
private
Long
lastModifiedUser
;
@ApiModelProperty
(
"最后修改时间"
)
private
Date
lastModifiedDate
;
@ApiModelProperty
(
"导出状态"
)
private
Integer
exportStatus
;
@Override
@Override
public
Long
getId
()
{
public
Long
getId
()
{
return
id
;
return
id
;
...
@@ -102,6 +110,30 @@ public class BookExportRecord extends BaseEntity {
...
@@ -102,6 +110,30 @@ public class BookExportRecord extends BaseEntity {
this
.
createdDate
=
createdDate
;
this
.
createdDate
=
createdDate
;
}
}
public
Long
getLastModifiedUser
()
{
return
lastModifiedUser
;
}
public
void
setLastModifiedUser
(
Long
lastModifiedUser
)
{
this
.
lastModifiedUser
=
lastModifiedUser
;
}
public
Date
getLastModifiedDate
()
{
return
lastModifiedDate
;
}
public
void
setLastModifiedDate
(
Date
lastModifiedDate
)
{
this
.
lastModifiedDate
=
lastModifiedDate
;
}
public
Integer
getExportStatus
()
{
return
exportStatus
;
}
public
void
setExportStatus
(
Integer
exportStatus
)
{
this
.
exportStatus
=
exportStatus
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"BookExportRecord{"
+
return
"BookExportRecord{"
+
...
@@ -113,6 +145,9 @@ public class BookExportRecord extends BaseEntity {
...
@@ -113,6 +145,9 @@ public class BookExportRecord extends BaseEntity {
", downloadUrl='"
+
downloadUrl
+
'\''
+
", downloadUrl='"
+
downloadUrl
+
'\''
+
", createdUser="
+
createdUser
+
", createdUser="
+
createdUser
+
", createdDate="
+
createdDate
+
", createdDate="
+
createdDate
+
", lastModifiedUser="
+
lastModifiedUser
+
", lastModifiedDate="
+
lastModifiedDate
+
", exportStatus="
+
exportStatus
+
'}'
;
'}'
;
}
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/facade/BookAuthInfoFacade.java
View file @
ed52b7be
...
@@ -68,4 +68,10 @@ public interface BookAuthInfoFacade {
...
@@ -68,4 +68,10 @@ public interface BookAuthInfoFacade {
@RequestMapping
(
value
=
"listHaveSetAuthBook"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"listHaveSetAuthBook"
,
method
=
RequestMethod
.
POST
)
ResponseDto
<
PageBeanNew
>
listHaveSetAuthBook
(
@RequestHeader
(
"token"
)
String
token
,
@RequestBody
ListHaveAuthBookParam
listHaveAuthBookParam
)
ResponseDto
<
PageBeanNew
>
listHaveSetAuthBook
(
@RequestHeader
(
"token"
)
String
token
,
@RequestBody
ListHaveAuthBookParam
listHaveAuthBookParam
)
throws
PermissionException
,
BizException
;
throws
PermissionException
,
BizException
;
@ApiOperation
(
value
=
"是否有可以导出的"
,
httpMethod
=
"GET"
)
@RequestMapping
(
value
=
"isHaveExport"
,
method
=
RequestMethod
.
GET
)
ResponseDto
<
Boolean
>
isHaveExport
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
"bookId"
)
Long
bookId
,
@RequestParam
(
"channelId"
)
Long
channelId
)
throws
PermissionException
,
BizException
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/facade/impl/BookAuthInfoFacadeImpl.java
View file @
ed52b7be
...
@@ -101,4 +101,13 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade {
...
@@ -101,4 +101,13 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade {
PageBeanNew
pageBeanNew
=
bookAuthInfoBiz
.
listHaveSetAuthBook
(
listHaveAuthBookParam
,
adviserId
)
;
PageBeanNew
pageBeanNew
=
bookAuthInfoBiz
.
listHaveSetAuthBook
(
listHaveAuthBookParam
,
adviserId
)
;
return
new
ResponseDto
<>(
pageBeanNew
);
return
new
ResponseDto
<>(
pageBeanNew
);
}
}
@Override
@GetMapping
(
"isHaveExport"
)
public
ResponseDto
<
Boolean
>
isHaveExport
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
"bookId"
)
Long
bookId
,
@RequestParam
(
"channelId"
)
Long
channelId
)
throws
PermissionException
,
BizException
{
Long
adviserId
=
(
Long
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
PARTY_ID
);
Boolean
isCanExport
=
bookAuthInfoBiz
.
isHaveExport
(
bookId
,
channelId
,
adviserId
);
return
new
ResponseDto
<>(
isCanExport
==
null
?
false
:
isCanExport
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/mq/event/BookEvent.java
0 → 100644
View file @
ed52b7be
/**
*
*/
package
com
.
pcloud
.
book
.
mq
.
event
;
import
com.pcloud.book.copyright.biz.BookExportRecordBiz
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.stereotype.Component
;
/**
* @author:songx
* @date:2018年5月16日,下午5:11:03
*/
@Component
(
"bookEvent"
)
public
class
BookEvent
implements
ApplicationListener
<
ContextRefreshedEvent
>
{
/**
*
*/
private
final
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BookEvent
.
class
);
@Autowired
private
BookExportRecordBiz
bookExportRecordBiz
;
/**
* 目的:防止onApplicationEvent方法重复执行两次
*/
private
boolean
bool
=
false
;
public
void
onApplicationEvent
(
ContextRefreshedEvent
event
)
{
if
(
bool
||
!
StringUtil
.
isEmpty
(
event
.
getApplicationContext
().
getParent
().
getApplicationName
()))
{
return
;
}
bool
=
true
;
//处理由于服务重启导致导出失败的文件
handleExportFail
();
}
private
void
handleExportFail
()
{
bookExportRecordBiz
.
handleExportFail
();
}
}
pcloud-service-book/src/main/resources/mapper/copyright/BookExportRecord.Mapper.xml
View file @
ed52b7be
...
@@ -4,9 +4,53 @@
...
@@ -4,9 +4,53 @@
<insert
id=
"insert"
useGeneratedKeys=
"true"
parameterType=
"bookExportRecord"
>
<insert
id=
"insert"
useGeneratedKeys=
"true"
parameterType=
"bookExportRecord"
>
INSERT INTO BOOK_EXPORT_RECORD(
INSERT INTO BOOK_EXPORT_RECORD(
BOOK_ID, CHANNEL_ID,ADVISER_ID,
BATCH_NUM,DOWNLOAD_URL,
CREATED_USER, CREATED_DATE)
BOOK_ID, CHANNEL_ID,ADVISER_ID,
BATCH_NUM,
CREATED_USER, CREATED_DATE)
VALUES
VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
#{batchNum},
#{batchNum}, #{downloadUrl},
#{adviserId}, NOW())
#{adviserId}, NOW())
</insert>
</insert>
<update
id=
"updateRecordStatus"
parameterType=
"bookAuthInfo"
flushCache=
"true"
>
UPDATE BOOK_EXPORT_RECORD
SET
EXPORT_STATUS = #{exportStatus},
LAST_MODIFIED_DATE = NOW(),
LAST_MODIFIED_USER = #{lastModifiedUser}
WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum}
</update>
<update
id=
"updateRecord"
parameterType=
"bookAuthInfo"
flushCache=
"true"
>
UPDATE BOOK_EXPORT_RECORD
SET
EXPORT_STATUS = #{exportStatus},
download_url = #{downloadUrl},
LAST_MODIFIED_DATE = NOW(),
LAST_MODIFIED_USER = #{lastModifiedUser}
WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum}
</update>
<select
id=
"isHaveExport"
resultType=
"Boolean"
parameterType=
"map"
>
SELECT
COUNT(1)
FROM
BOOK_EXPORT_RECORD
WHERE
BOOK_ID = #{bookId, jdbcType=BIGINT}
AND
CHANNEL_ID = #{channelId, jdbcType=BIGINT}
AND
ADVISER_ID = #{adviserId, jdbcType=BIGINT}
AND EXPORT_STATUS = 0
</select>
<update
id=
"handleExportFail"
>
UPDATE BOOK_EXPORT_RECORD
SET EXPORT_STATUS = 2
WHERE EXPORT_STATUS = 0
</update>
</mapper>
</mapper>
\ No newline at end of file
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