remove unused code
This commit is contained in:
@@ -51,10 +51,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
private BookChapterService bookChapterService;
|
||||
@Autowired
|
||||
ConstantPropertiesUtils constantPropertiesUtils;
|
||||
@Autowired
|
||||
private BookForumArticlesService bookForumArticlesService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -62,10 +58,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
//出版社
|
||||
String publisherName1 = (String) params.get("publisherName");
|
||||
String state = (String) params.get("state");
|
||||
// String[] publisherName1split1 = publisherName1.split(",");
|
||||
// String join = StringUtils.join(publisherName1split1, "','");
|
||||
// 多查询语句
|
||||
// String sql = "IN_SET(publisher_id, (SELECT GROUP_CONCAT(id) FROM publisher WHERE publisher_name in ('\"+ join +\"'))) = 1";
|
||||
//类型
|
||||
String typeC = (String) params.get("type");
|
||||
//作者
|
||||
@@ -102,15 +94,9 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
.eq("dict_type", voicesStatus).eq("dict_label", "processing_results"));
|
||||
|
||||
String chapterStatusName = chapter.getDictValue();
|
||||
|
||||
String contentStatusName = content.getDictValue();
|
||||
|
||||
String voicesStatusName = voices.getDictValue();
|
||||
|
||||
|
||||
String[] split = type.split(",");
|
||||
|
||||
|
||||
for (String tp : split) {
|
||||
SysDictDataEntity dict = sysDictDataService.getBaseMapper().selectOne(new QueryWrapper<SysDictDataEntity>()
|
||||
.eq("dict_type", tp).eq("dict_label", "book_type"));
|
||||
@@ -120,13 +106,10 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
}
|
||||
String authorId = book.getAuthorId();
|
||||
String publisherId = book.getPublisherId();
|
||||
|
||||
String[] authorIds = authorId.split(",");
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
@@ -165,77 +148,40 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
public void getChapter(Integer id) {
|
||||
|
||||
BookEntity bookEntity = this.baseMapper.selectById(id);
|
||||
|
||||
String novel = bookEntity.getNovel();
|
||||
|
||||
Integer bookEntityId = bookEntity.getId();
|
||||
|
||||
// String fileName = novel.split("/")[novel.split("/").length - 1];
|
||||
|
||||
String fileName = novel.replace("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/", "");
|
||||
|
||||
Long count = (long) 0;
|
||||
boolean bflag = false;
|
||||
int n = 0;
|
||||
String newStr = null;
|
||||
String titleName = null; //旧章节
|
||||
String titleName; //旧章节
|
||||
String newChapterName = null;//新章节名称
|
||||
String substring = null;
|
||||
int indexOf = 0;
|
||||
int indexOf1 = 0;
|
||||
int linecount = 0;
|
||||
|
||||
// ArrayList<Object> chapterList = new ArrayList<>();
|
||||
// ArrayList<Object> contentList = new ArrayList<>();
|
||||
|
||||
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(constantPropertiesUtils.END_POIND, constantPropertiesUtils.ACCESS_KEY_ID, constantPropertiesUtils.ACCESS_KEY_SECRET);
|
||||
try {
|
||||
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
|
||||
OSSObject ossObject = ossClient.getObject(constantPropertiesUtils.BUCKET_NAME, fileName);
|
||||
|
||||
// 读取文件内容。
|
||||
// System.out.println("Object content:");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(ossObject.getObjectContent(), "UTF-8"));
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
|
||||
if (line == null) break;
|
||||
|
||||
|
||||
BookChapterEntity content = new BookChapterEntity();
|
||||
|
||||
count++;
|
||||
// 正则表达式
|
||||
Pattern p = Pattern.compile("(^\\s*第)(.{1,9})[章节卷集部篇回讲](\\s{1})(.*)($\\s*)");
|
||||
|
||||
Matcher matcher = p.matcher(line);
|
||||
Matcher matcher1 = p.matcher(line);
|
||||
|
||||
newStr = newStr + line;
|
||||
|
||||
|
||||
while (matcher.find()) {
|
||||
|
||||
if (StringUtils.isNotBlank(newChapterName)) {
|
||||
content.setChapter(newChapterName.trim());
|
||||
}
|
||||
titleName = matcher.group();
|
||||
//章节去空
|
||||
newChapterName = titleName.trim();
|
||||
|
||||
//获取章节
|
||||
// System.out.println(newChapterName);
|
||||
// content.setChapter(newChapterName);
|
||||
// content.setNumber(++linecount);
|
||||
// chapterList.add(newChapterName);
|
||||
indexOf1 = indexOf;
|
||||
// System.out.println("indexOf" + indexOf);
|
||||
indexOf = newStr.indexOf(newChapterName);
|
||||
|
||||
|
||||
// System.out.println(newChapterName + ":" + "第" + count + "行"); // 得到返回的章
|
||||
if (bflag) {
|
||||
bflag = false;
|
||||
break;
|
||||
@@ -246,7 +192,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
}
|
||||
n = 1;
|
||||
bflag = true;
|
||||
//System.out.println(chapter);
|
||||
}
|
||||
|
||||
|
||||
@@ -258,14 +203,10 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
content.setBookId(bookEntityId);
|
||||
content.setNumber(++linecount);
|
||||
System.out.println(substring);
|
||||
// contentList.add(substring);
|
||||
System.out.println(content.toString());
|
||||
bookChapterService.save(content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
|
||||
reader.close();
|
||||
@@ -273,11 +214,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
// 致请求无连接可用,程序无法正常工作。
|
||||
ossObject.close();
|
||||
bookEntity.setChapterStatus("2");
|
||||
//
|
||||
// System.out.println(chapterList);
|
||||
// System.out.println(contentList);
|
||||
|
||||
|
||||
} catch (OSSException oe) {
|
||||
bookEntity.setChapterStatus("3");
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
@@ -310,7 +246,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
);
|
||||
|
||||
List<BookEntity> newBookList = page.getRecords();
|
||||
|
||||
for (BookEntity book : newBookList) {
|
||||
String authorName = "";
|
||||
String publisherName = "";
|
||||
@@ -325,13 +260,10 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
|
||||
|
||||
String publisherId = book.getPublisherId();
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
@@ -339,8 +271,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
book.setPublisherName(publisherName);
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@@ -349,11 +279,12 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
Object id = params.get("id");
|
||||
IPage<BookEntity> page = this.page(
|
||||
new Query<BookEntity>().getPage(params),
|
||||
new QueryWrapper<BookEntity>().eq("id",id)
|
||||
new QueryWrapper<BookEntity>().eq("id", id)
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public PageUtils getNewBook(Map<String, Object> params) {
|
||||
|
||||
IPage<BookEntity> page = this.page(
|
||||
@@ -371,19 +302,14 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
String[] authorIds = authorId.split(",");
|
||||
List<String> authorList = Arrays.asList(authorIds);
|
||||
List<AuthorEntity> authorEntities = authorService.getBaseMapper().selectList(new QueryWrapper<AuthorEntity>().in("id", authorList));
|
||||
|
||||
for (AuthorEntity authorEntity : authorEntities) {
|
||||
authorName += "," + authorEntity.getAuthorName();
|
||||
}
|
||||
|
||||
authorName = authorName.startsWith(",") ? authorName.substring(1) : authorName;
|
||||
|
||||
|
||||
String publisherId = book.getPublisherId();
|
||||
String[] publisherIds = publisherId.split(",");
|
||||
List<String> publisherList = Arrays.asList(publisherIds);
|
||||
List<PublisherEntity> publisherEntities = publisherService.getBaseMapper().selectList(new QueryWrapper<PublisherEntity>().in("id", publisherList));
|
||||
|
||||
for (PublisherEntity publisherEntity : publisherEntities) {
|
||||
publisherName += "," + publisherEntity.getPublisherName();
|
||||
}
|
||||
@@ -391,8 +317,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
book.setPublisherName(publisherName);
|
||||
book.setAuthorName(authorName);
|
||||
}
|
||||
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@@ -454,7 +378,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
System.out.println(StringUtils.isNotBlank(paragraph.getText().trim()));
|
||||
//获取标题
|
||||
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
|
||||
// if (paragraph.getStyleName().equals("Normal") && StringUtils.isNotBlank(paragraph.getText().trim()))//段落样式为“标题1”的内容
|
||||
{
|
||||
num++;
|
||||
|
||||
@@ -472,7 +395,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
//todo 章节拆分 按照章节保存
|
||||
@Override
|
||||
public boolean getWord(Integer bookId) {
|
||||
BookEntity bookEntity = this.getBaseMapper().selectById(bookId);
|
||||
@@ -484,35 +406,8 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
Section section = doc.getSections().get(i);
|
||||
//遍历Paragraph,每个小节下有若干段落
|
||||
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
|
||||
|
||||
//插入分页符到小节下若干段落
|
||||
Paragraph paragraph = section.getParagraphs().get(j);
|
||||
|
||||
//插入分页符到第五个段落
|
||||
// Paragraph paragraph = section.getParagraphs().get(4);
|
||||
|
||||
//获取标题
|
||||
|
||||
|
||||
// int cj = 0;
|
||||
// if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
|
||||
// cj = 2;
|
||||
// }
|
||||
// if (section.getParagraphs().get(j).getStyleName().equals("Heading3")) {
|
||||
// cj = 3;
|
||||
// }
|
||||
// if (section.getParagraphs().get(j).getStyleName().equals("Heading4")) {
|
||||
// cj = 4;
|
||||
// }
|
||||
// int cj= 0;
|
||||
// if (section.getParagraphs().get(j).getStyleName().equals("Heading2")) {
|
||||
//// cj = 2;
|
||||
// }
|
||||
// if(section.getParagraphs().get(j).getStyleName().equals(""))
|
||||
|
||||
if (paragraph.getStyleName().equals("Heading1") && StringUtils.isNotBlank(paragraph.getText().trim())) {
|
||||
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
do {
|
||||
builder.append(section.getParagraphs().get(j).getText());
|
||||
@@ -543,11 +438,11 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
|
||||
|
||||
/**
|
||||
* number章节号变小节号
|
||||
* 如果上传文档为只有heading1标题,则按照标题1进行拆分
|
||||
* 如果上传文档的heading1标题下有heading2标题,则按照标题2进行拆分
|
||||
* @param bookId 图书ID
|
||||
* number章节号变小节号
|
||||
* 如果上传文档为只有heading1标题,则按照标题1进行拆分
|
||||
* 如果上传文档的heading1标题下有heading2标题,则按照标题2进行拆分
|
||||
*
|
||||
* @param bookId 图书ID
|
||||
* @return0
|
||||
*/
|
||||
@Override
|
||||
@@ -556,29 +451,26 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
String novel = bookEntity.getNovel();
|
||||
InputStream inputStream = FileDownloadUtil.getInputStream(novel);
|
||||
Document doc = new Document(inputStream);
|
||||
int nums = 0;
|
||||
String title2Text = "";
|
||||
int num1=0;
|
||||
|
||||
Map<String,List<String[]>> paraMap = new HashMap<>();
|
||||
Map<String,String> headMap = new HashMap<>();
|
||||
Map<String, List<String[]>> paraMap = new HashMap<>();
|
||||
Map<String, String> headMap = new HashMap<>();
|
||||
List<String> title_list = new ArrayList<>();
|
||||
for (int i = 0; i < doc.getSections().getCount(); i++) {
|
||||
String currentTitle = "";
|
||||
Section section = doc.getSections().get(i);
|
||||
for (int j = 0; j < section.getParagraphs().getCount() - 1; j++) {
|
||||
Paragraph paragraph = section.getParagraphs().get(j);
|
||||
if (paragraph.getStyleName().equals("Heading1") ) {
|
||||
if (paragraph.getStyleName().equals("Heading1")) {
|
||||
String textq = paragraph.getText();
|
||||
currentTitle = textq;
|
||||
title_list.add(currentTitle);
|
||||
List<String[]> secondTitleList = new ArrayList<>();
|
||||
paraMap.put(currentTitle,secondTitleList);
|
||||
if(!section.getParagraphs().get(j+1).getStyleName().matches("Heading2")){
|
||||
int head_index = j ;
|
||||
paraMap.put(currentTitle, secondTitleList);
|
||||
if (!section.getParagraphs().get(j + 1).getStyleName().matches("Heading2")) {
|
||||
int head_index = j;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
do {
|
||||
builder.append(section.getParagraphs().get(head_index).getText());
|
||||
builder.append(section.getParagraphs().get(head_index).getText());
|
||||
head_index++;
|
||||
//防止index超出异常发生
|
||||
if (head_index >= section.getParagraphs().getCount()) {
|
||||
@@ -586,14 +478,14 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
}
|
||||
} while (!section.getParagraphs().get(head_index).getStyleName().equals("Heading2"));
|
||||
String head_text = builder.toString();
|
||||
headMap.put(currentTitle,head_text);
|
||||
headMap.put(currentTitle, head_text);
|
||||
|
||||
}
|
||||
} else if (paragraph.getStyleName().equals("Heading2") && StringUtils.isNotBlank(paragraph.getText().trim())) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean isRun = false;
|
||||
do {
|
||||
if(isRun){
|
||||
if (isRun) {
|
||||
builder.append(section.getParagraphs().get(j).getText());
|
||||
}
|
||||
isRun = true;
|
||||
@@ -602,57 +494,44 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
if (j >= section.getParagraphs().getCount()) {
|
||||
break;
|
||||
}
|
||||
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading2")&&!section.getParagraphs().get(j).getStyleName().equals("Heading1"));
|
||||
j --;
|
||||
} while (!section.getParagraphs().get(j).getStyleName().equals("Heading2") && !section.getParagraphs().get(j).getStyleName().equals("Heading1"));
|
||||
j--;
|
||||
String text = builder.toString();
|
||||
nums++;
|
||||
title2Text = paragraph.getText(); // 获取标题二的文本内容
|
||||
if(null != title2Text && !"".equals(title2Text)){
|
||||
String [] s = new String[]{title2Text,text};
|
||||
|
||||
if (null != title2Text && !"".equals(title2Text)) {
|
||||
String[] s = new String[]{title2Text, text};
|
||||
paraMap.get(currentTitle).add(s);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
int index = 0;
|
||||
for(String title: title_list){
|
||||
if(null == paraMap.get(title) || paraMap.get(title).size() == 0){
|
||||
index ++ ;
|
||||
for (String title : title_list) {
|
||||
if (null == paraMap.get(title) || paraMap.get(title).size() == 0) {
|
||||
index++;
|
||||
BookChapterEntity bookChapterEntity = new BookChapterEntity();
|
||||
|
||||
bookChapterEntity.setBookId(bookId);
|
||||
bookChapterEntity.setNumber(index);
|
||||
bookChapterEntity.setChapter(title);
|
||||
bookChapterEntity.setSort(1);
|
||||
if(null != headMap.get(title)){
|
||||
|
||||
if (null != headMap.get(title)) {
|
||||
bookChapterEntity.setContent(headMap.get(title));
|
||||
}else {
|
||||
} else {
|
||||
bookChapterEntity.setContent("");
|
||||
|
||||
}
|
||||
|
||||
bookChapterService.save(bookChapterEntity);
|
||||
|
||||
|
||||
}else {
|
||||
for(String[] t : paraMap.get(title)){
|
||||
index ++;
|
||||
} else {
|
||||
for (String[] t : paraMap.get(title)) {
|
||||
index++;
|
||||
BookChapterEntity bookChapterEntity = new BookChapterEntity();
|
||||
bookChapterEntity.setBookId(bookId);
|
||||
bookChapterEntity.setSort(2);
|
||||
bookChapterEntity.setNumber(index);
|
||||
bookChapterEntity.setChapter(title+","+t[0]);
|
||||
bookChapterEntity.setContent(t[1]);
|
||||
|
||||
bookChapterEntity.setChapter(title + "," + t[0]);
|
||||
bookChapterEntity.setContent(t[1]);
|
||||
bookChapterService.save(bookChapterEntity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -702,18 +581,16 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
if (!StringUtils.isEmpty(publisherName)) {
|
||||
book.setPublisherName(publisherName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<BookEntity> getUserClockBooks(Integer userId, Integer limit, Integer page) {
|
||||
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = "+userId;
|
||||
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = " + userId;
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookEntity::getClockIn,1);
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
wrapper.eq(BookEntity::getClockIn, 1);
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.exists(exist_sql);
|
||||
Page<BookEntity> bookEntityPage = this.getBaseMapper().selectPage(new Page<BookEntity>(page, limit), wrapper);
|
||||
return bookEntityPage;
|
||||
@@ -722,15 +599,12 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
|
||||
@Override
|
||||
public Page<BookEntity> getUserClockBestBooks(Integer userId, Integer limit, Integer page) {
|
||||
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = "+userId;
|
||||
String exist_sql = "select 1 from user_ebook_buy where book_id = book.id and user_id = " + userId;
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookEntity::getClockIn,1);
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
wrapper.eq(BookEntity::getClockIn, 1);
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.notExists(exist_sql);
|
||||
Page<BookEntity> bookEntityPage = this.getBaseMapper().selectPage(new Page<BookEntity>(page, limit), wrapper);
|
||||
return bookEntityPage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user