Commit 20335180 by 朱亚洁

feat:[1005102]搜答案优化

parent 9dfe5621
...@@ -832,6 +832,54 @@ public class BookDto extends BaseDto { ...@@ -832,6 +832,54 @@ public class BookDto extends BaseDto {
//是否开启手机号登录 //是否开启手机号登录
private Integer bookPhoneAuth; private Integer bookPhoneAuth;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
/**
* 上下册
*/
private String label4;
public String getLabel1() {
return label1;
}
public void setLabel1(String label1) {
this.label1 = label1;
}
public String getLabel2() {
return label2;
}
public void setLabel2(String label2) {
this.label2 = label2;
}
public String getLabel3() {
return label3;
}
public void setLabel3(String label3) {
this.label3 = label3;
}
public String getLabel4() {
return label4;
}
public void setLabel4(String label4) {
this.label4 = label4;
}
private Integer isWechatAuth; private Integer isWechatAuth;
......
package com.pcloud.book.book.biz; package com.pcloud.book.book.biz;
import com.pcloud.book.book.entity.BookLabel; import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.book.book.vo.BookLabelVO; import com.pcloud.book.book.vo.BookLabelVO;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -72,4 +74,23 @@ public interface BookLabelBiz { ...@@ -72,4 +74,23 @@ public interface BookLabelBiz {
* @return * @return
*/ */
List<BookLabel> getBookLabelsByType(Integer labelType); List<BookLabel> getBookLabelsByType(Integer labelType);
void addBookNewLabel(List<Long> bookIds);
/**
* 查标签
* @author:zhuyajie
* @date:2021/7/27 14:44
* * @param null
*/
Map<Long, BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds);
/**
* 整理后的标签
* @author:zhuyajie
* @date:2021/7/27 15:46
* * @param null
*/
List<BookLabelTrim> getBookLabelTrimList(Integer type);
} }
...@@ -2510,7 +2510,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -2510,7 +2510,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
@Override @Override
public List<BookServeDTO> getAnswerServesByBook(Long bookId, Long adviserId, Long channelId) { public List<BookServeDTO> getAnswerServesByBook(Long bookId, Long adviserId, Long channelId) {
List<BookServeDTO> answerList = new ArrayList<>(); List<BookServeDTO> answerList = new ArrayList<>();
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(adviserId, bookId, channelId); List<BookServeDTO> bookServeVOS = resourcePageBiz.getBookAllServeIdsIncludeUrl(adviserId, bookId, channelId);
bookGroupBiz.fillBookServe(bookServeVOS); bookGroupBiz.fillBookServe(bookServeVOS);
bookGroupBiz.removeCanNotBuy(bookServeVOS); bookGroupBiz.removeCanNotBuy(bookServeVOS);
if (!ListUtils.isEmpty(bookServeVOS)) { if (!ListUtils.isEmpty(bookServeVOS)) {
......
...@@ -63,6 +63,7 @@ import com.pcloud.book.copyright.vo.BookAuthInfoVO; ...@@ -63,6 +63,7 @@ import com.pcloud.book.copyright.vo.BookAuthInfoVO;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz; import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.es.entity.ESBookAndAdviser; import com.pcloud.book.es.entity.ESBookAndAdviser;
import com.pcloud.book.group.biz.BookGroupBiz; import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.book.group.dao.BookAppletSceneDao; import com.pcloud.book.group.dao.BookAppletSceneDao;
import com.pcloud.book.group.dao.BookGroupDao; import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.BookGroupServeDao; import com.pcloud.book.group.dao.BookGroupServeDao;
...@@ -197,9 +198,6 @@ public class BookBizImpl implements BookBiz { ...@@ -197,9 +198,6 @@ public class BookBizImpl implements BookBiz {
private BookGroupBiz bookGroupBiz; private BookGroupBiz bookGroupBiz;
@Autowired @Autowired
private BookLabelDao bookLabelDao; private BookLabelDao bookLabelDao;
@Autowired
private ExportService exportService;
@Autowired @Autowired
private ExportConsr exportConsr; private ExportConsr exportConsr;
@Autowired @Autowired
...@@ -216,6 +214,8 @@ public class BookBizImpl implements BookBiz { ...@@ -216,6 +214,8 @@ public class BookBizImpl implements BookBiz {
@Autowired @Autowired
private BookAdviserDao bookAdviserDao; private BookAdviserDao bookAdviserDao;
@Autowired
private ResourcePageBiz resourcePageBiz;
@Autowired @Autowired
...@@ -3677,17 +3677,9 @@ public class BookBizImpl implements BookBiz { ...@@ -3677,17 +3677,9 @@ public class BookBizImpl implements BookBiz {
@Override @Override
public PageBeanNew<BookDto> getESAdviserBooks4Answer(Long wechatUserId, BookSearchParamVO bookSearchParamVO) { public PageBeanNew<BookDto> getESAdviserBooks4Answer(Long wechatUserId, BookSearchParamVO bookSearchParamVO) {
Long graLabelId = bookSearchParamVO.getGraLabelId();
Long subLabelId = bookSearchParamVO.getSubLabelId();
Long verLabelId = bookSearchParamVO.getVerLabelId();
Integer currentPage = bookSearchParamVO.getCurrentPage() == null?0:bookSearchParamVO.getCurrentPage(); Integer currentPage = bookSearchParamVO.getCurrentPage() == null?0:bookSearchParamVO.getCurrentPage();
Integer numPerPage = bookSearchParamVO.getNumPerPage() == null?10:bookSearchParamVO.getNumPerPage(); Integer numPerPage = bookSearchParamVO.getNumPerPage() == null?10:bookSearchParamVO.getNumPerPage();
List<Long> templetIds = new ArrayList<>(); Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getESAdviserBooks4Answer(bookSearchParamVO);
if (null != graLabelId || null != subLabelId || null != verLabelId){
templetIds = Arrays.asList(RightsSettingConstant.K12_TEMPLET_ID_NEW);
}
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getESAdviserBooks4Answer(bookSearchParamVO.getGrayStatus(), bookSearchParamVO.getKeyword(),
graLabelId, subLabelId, verLabelId, currentPage, numPerPage, templetIds);
List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent(); List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent();
if (ListUtils.isEmpty(esBookAndAdvisers)) { if (ListUtils.isEmpty(esBookAndAdvisers)) {
return new PageBeanNew<>(currentPage, numPerPage, (int) esPage.getTotalElements(),new ArrayList<>()); return new PageBeanNew<>(currentPage, numPerPage, (int) esPage.getTotalElements(),new ArrayList<>());
...@@ -3697,7 +3689,7 @@ public class BookBizImpl implements BookBiz { ...@@ -3697,7 +3689,7 @@ public class BookBizImpl implements BookBiz {
for (BookDto bookDto : bookDtos) { for (BookDto bookDto : bookDtos) {
bookDto.setHasAnswer(false); bookDto.setHasAnswer(false);
//标记是否有答案 //标记是否有答案
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(bookDto.getAdviserId(), bookDto.getBookId(), bookDto.getChannelId()); List<BookServeDTO> bookServeVOS = resourcePageBiz.getBookAllServeIdsIncludeUrl(bookDto.getAdviserId(), bookDto.getBookId(), bookDto.getChannelId());
bookGroupBiz.fillBookServe(bookServeVOS); bookGroupBiz.fillBookServe(bookServeVOS);
bookGroupBiz.removeCanNotBuy(bookServeVOS); bookGroupBiz.removeCanNotBuy(bookServeVOS);
if (!ListUtils.isEmpty(bookServeVOS)) { if (!ListUtils.isEmpty(bookServeVOS)) {
...@@ -3720,7 +3712,6 @@ public class BookBizImpl implements BookBiz { ...@@ -3720,7 +3712,6 @@ public class BookBizImpl implements BookBiz {
} }
bookDto.setSubscribeState(subscribeState); bookDto.setSubscribeState(subscribeState);
} }
bookSet.setLabelNames(bookDtos);
PageBeanNew<BookDto> page = new PageBeanNew<>(currentPage, numPerPage, (int) esPage.getTotalElements(), bookDtos); PageBeanNew<BookDto> page = new PageBeanNew<>(currentPage, numPerPage, (int) esPage.getTotalElements(), bookDtos);
return page; return page;
} }
......
package com.pcloud.book.book.biz.impl; package com.pcloud.book.book.biz.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookLabelBiz; import com.pcloud.book.book.biz.BookLabelBiz;
import com.pcloud.book.book.constant.BookConstant; import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dao.BookLabelDao; import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dao.BookLabelTrimDao;
import com.pcloud.book.book.dao.BookLabelTrimRelateDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.entity.BookLabel; import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.book.book.enums.BookLabelAuditState; import com.pcloud.book.book.enums.BookLabelAuditState;
import com.pcloud.book.book.vo.BookLabelVO; import com.pcloud.book.book.vo.BookLabelVO;
import com.pcloud.book.consumer.user.AdviserConsr; import com.pcloud.book.consumer.user.AdviserConsr;
...@@ -30,16 +39,25 @@ import java.util.List; ...@@ -30,16 +39,25 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import static com.pcloud.book.book.constant.BookConstant.BOOK_CACHE_SECOUND; import static com.pcloud.book.book.constant.BookConstant.BOOK_CACHE_SECOUND;
@Component("bookLabelBiz") @Component("bookLabelBiz")
@Slf4j
public class BookLabelBizImpl implements BookLabelBiz { public class BookLabelBizImpl implements BookLabelBiz {
@Autowired @Autowired
private BookLabelDao bookLabelDao; private BookLabelDao bookLabelDao;
@Autowired @Autowired
private AdviserConsr adviserConsr; private AdviserConsr adviserConsr;
@Autowired
private BookLabelTrimRelateDao bookLabelTrimRelateDao;
@Autowired
private BookDao bookDao;
@Autowired
private BookLabelTrimDao bookLabelTrimDao;
@Override @Override
public void applyBookLabel(BookLabel bookLabel, String systemCode) { public void applyBookLabel(BookLabel bookLabel, String systemCode) {
...@@ -191,4 +209,68 @@ public class BookLabelBizImpl implements BookLabelBiz { ...@@ -191,4 +209,68 @@ public class BookLabelBizImpl implements BookLabelBiz {
} }
return ListUtils.isEmpty(bookLabels) ? new ArrayList<>() : bookLabels; return ListUtils.isEmpty(bookLabels) ? new ArrayList<>() : bookLabels;
} }
/* private Map<String, Object> getLabel(Long bookId, String bookName) {
Map<String, Object> labelMap = new HashMap<>();
try {
JSONObject dataJsonObj = new JSONObject();
dataJsonObj.put(bookId.toString(), bookName);
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", dataJsonObj);
jsonObject.put("type", "book");
String response = HttpUtil.post("http://192.168.82.152:8000/getLabels", jsonObject.toString());
// 解析结果
JSONObject object = JSONObject.parseObject(response);
log.info("标签解析结果==" + object.toString());
if (!"success".equals(object.getString("info")) || StringUtil.isEmpty(object.getString("data"))) {
return null;
}
Map<String, Object> stringObjectMap = JSON.parseObject(object.getString("data"), new TypeReference<Map<String, Object>>() {
});
if (null == stringObjectMap.get(bookId.toString())) {
return null;
}
labelMap = (Map<String, Object>) stringObjectMap.get(bookId.toString());
} catch (Exception e) {
log.error("调用查标签失败" + e.getMessage(), e);
}
return labelMap;
}*/
@Override
public void addBookNewLabel(List<Long> bookIds) {
if(ListUtils.isEmpty(bookIds)) {
return;
}
Map<Long,BookDto> bookDtoMap = bookDao.getMapByBookIds(bookIds);
if (MapUtils.isEmpty(bookDtoMap)) {
return;
}
/* List<BookLabelTrimRelate> list = new ArrayList<>();
for (BookDto bookDto:bookDtoMap.values()){
Map<String, Object> labelMap = this.getLabel(bookDto.getBookId(), bookDto.getBookName());
BookLabelTrimRelate labelTrimRelate = new BookLabelTrimRelate();
labelTrimRelate.setBookId(bookDto.getBookId());
labelTrimRelate.setLabel1((String) labelMap.get("label1"));
labelTrimRelate.setLabel2((String) labelMap.get("label2"));
labelTrimRelate.setLabel3((String) labelMap.get("label3"));
labelTrimRelate.setLabel4((String) labelMap.get("label4"));
list.add(labelTrimRelate);
}
bookLabelTrimRelateDao.insert(list);*/
}
@Override
public Map<Long, BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds) {
if (ListUtils.isEmpty(bookIds)) {
return new HashMap<>();
}
return bookLabelTrimRelateDao.mapBookTrimLabel(bookIds);
}
@Override
public List<BookLabelTrim> getBookLabelTrimList(Integer type) {
return bookLabelTrimDao.getBookLabelTrimList(type);
}
} }
package com.pcloud.book.book.dao;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* 书刊标签(整理后)(BookLabelTrim)表数据库访问层
*
* @author makejava
* @since 2021-07-27 11:17:51
*/
public interface BookLabelTrimDao extends BaseDao<BookLabelTrim>{
List<BookLabelTrim> getBookLabelTrimList(Integer type);
}
\ No newline at end of file
package com.pcloud.book.book.dao;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* 书刊对应整理后的标签(BookLabelTrimRelate)表数据库访问层
*
* @author makejava
* @since 2021-07-27 11:18:24
*/
public interface BookLabelTrimRelateDao extends BaseDao<BookLabelTrimRelate> {
/**
* 批量查标签
* @author:zhuyajie
* @date:2021/7/27 14:46
* * @param null
*/
Map<Long,BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds);
}
\ No newline at end of file
package com.pcloud.book.book.dao.impl;
import com.pcloud.book.book.dao.BookLabelTrimDao;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName com.pcloud.book.book.dao.impl.BookLabelTrimDaoImpl
* @Author zhuyajie
* @Description 新标签
* @Date 2021/7/27 11:26
* @Version 1.0
**/
@Component
public class BookLabelTrimDaoImpl extends BaseDaoImpl<BookLabelTrim> implements BookLabelTrimDao {
@Override
public List<BookLabelTrim> getBookLabelTrimList(Integer type) {
Map<String, Object> map = new HashMap<>();
map.put("type", type);
return getSessionTemplate().selectList(getStatement("getBookLabelTrimList"), map);
}
}
package com.pcloud.book.book.dao.impl;
import com.pcloud.book.book.dao.BookLabelTrimRelateDao;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName com.pcloud.book.book.dao.impl.BookLabelTrimRelateDaoImpl
* @Author zhuyajie
* @Description 新标签
* @Date 2021/7/27 11:27
* @Version 1.0
**/
@Component
public class BookLabelTrimRelateDaoImpl extends BaseDaoImpl<BookLabelTrimRelate> implements BookLabelTrimRelateDao {
@Override
public Map<Long, BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds) {
Map<String, Object> map = new HashMap<>();
map.put("bookIds", bookIds);
return getSessionTemplate().selectMap(getStatement("mapBookTrimLabel"), map ,"bookId");
}
}
package com.pcloud.book.book.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
/**
* 书刊标签(整理后)(BookLabelTrim)实体类
*
* @author makejava
* @since 2021-07-27 11:17:51
*/
@Data
public class BookLabelTrim extends BaseEntity {
private static final long serialVersionUID = 155647419272841884L;
/**
* 主键
*/
private Long id;
/**
* 标签名称
*/
private String name;
/**
* 类型:1科目,2年级,3版本,4上下册
*/
private Integer type;
}
\ No newline at end of file
package com.pcloud.book.book.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
/**
* 书刊对应整理后的标签(BookLabelTrimRelate)实体类
*
* @author makejava
* @since 2021-07-27 11:18:24
*/
@Data
public class BookLabelTrimRelate extends BaseEntity {
private static final long serialVersionUID = -59204152090408165L;
/**
* 主键
*/
private Long id;
/**
* 书刊id
*/
private Long bookId;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
/**
* 上下册
*/
private String label4;
}
\ No newline at end of file
...@@ -140,4 +140,17 @@ public class BookLabelFacadeImpl { ...@@ -140,4 +140,17 @@ public class BookLabelFacadeImpl {
return new ResponseDto<>(bookLabels); return new ResponseDto<>(bookLabels);
} }
@PostMapping("addBookNewLabel")
public ResponseDto<?> addBookNewLabel(@RequestBody List<Long> bookIds) {
bookLabelBiz.addBookNewLabel(bookIds);
return new ResponseDto<>();
}
@ApiOperation("整理后的书刊标签")
@GetMapping("getBookLabelTrimList")
public ResponseDto<?> getBookLabelTrimList(
@RequestParam(value = "type", required = false) Integer type) {
return new ResponseDto<>(bookLabelBiz.getBookLabelTrimList(type));
}
} }
...@@ -40,4 +40,16 @@ public class BookSearchParamVO { ...@@ -40,4 +40,16 @@ public class BookSearchParamVO {
private List<Long> choseBookIdList; private List<Long> choseBookIdList;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
} }
package com.pcloud.book.es.biz; package com.pcloud.book.es.biz;
import com.pcloud.book.book.vo.request.BookSearchParamVO;
import com.pcloud.book.es.entity.ESBookAndAdviser; import com.pcloud.book.es.entity.ESBookAndAdviser;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -32,8 +33,7 @@ public interface ESBookAndAdviserBiz { ...@@ -32,8 +33,7 @@ public interface ESBookAndAdviserBiz {
* @date:2020/11/4 13:52 * @date:2020/11/4 13:52
* * @param null * * @param null
*/ */
Page<ESBookAndAdviser> getESAdviserBooks4Answer(String grayStatus, String keyword, Long graLabelId, Long subLabelId, Long verLabelId, Page<ESBookAndAdviser> getESAdviserBooks4Answer(BookSearchParamVO bookSearchParamVO);
Integer currentPage, Integer numPerPage, List<Long> templetIds);
/** /**
* 系列书搜索 * 系列书搜索
* @author:zhuyajie * @author:zhuyajie
......
...@@ -5,14 +5,13 @@ import cn.hutool.core.map.MapUtil; ...@@ -5,14 +5,13 @@ import cn.hutool.core.map.MapUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.pcloud.analysisengine.browse.dto.BrowseCacheRecordDto; import com.pcloud.analysisengine.browse.dto.BrowseCacheRecordDto;
import com.pcloud.book.applet.biz.AppletBookIgnorBiz; import com.pcloud.book.applet.biz.AppletBookIgnorBiz;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz; import com.pcloud.book.book.biz.BookLabelBiz;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.constant.BookConstant; import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookAdviserDao; import com.pcloud.book.book.dao.BookAdviserDao;
import com.pcloud.book.book.dao.BookDao; import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.book.book.vo.request.BookSearchParamVO;
import com.pcloud.book.consumer.analysisengine.BrowseRecordConsr; import com.pcloud.book.consumer.analysisengine.BrowseRecordConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.consumer.trade.TradeConsr; import com.pcloud.book.consumer.trade.TradeConsr;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz; import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.es.entity.ESBookAndAdviser; import com.pcloud.book.es.entity.ESBookAndAdviser;
...@@ -20,12 +19,10 @@ import com.pcloud.book.es.repository.BookAndAdviserRepository; ...@@ -20,12 +19,10 @@ import com.pcloud.book.es.repository.BookAndAdviserRepository;
import com.pcloud.book.group.biz.BookGroupBiz; import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.ResourcePageBiz; import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.book.group.dto.BookServeDTO; import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant; import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.common.YesOrNoEnums; import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.book.util.properties.BookProps; import com.pcloud.book.util.properties.BookProps;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.enums.AppTypeEnum; import com.pcloud.common.enums.AppTypeEnum;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -46,7 +43,6 @@ import org.elasticsearch.index.query.BoolQueryBuilder; ...@@ -46,7 +43,6 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.WildcardQueryBuilder; import org.elasticsearch.index.query.WildcardQueryBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -98,6 +94,8 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -98,6 +94,8 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
private ResourcePageBiz resourcePageBiz; private ResourcePageBiz resourcePageBiz;
@Autowired @Autowired
private AppletBookIgnorBiz appletBookIgnorBiz; private AppletBookIgnorBiz appletBookIgnorBiz;
@Autowired
private BookLabelBiz bookLabelBiz;
@ParamLog("导入全部book和bookAdviser") @ParamLog("导入全部book和bookAdviser")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -118,7 +116,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -118,7 +116,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
if (ListUtils.isEmpty(list)) { if (ListUtils.isEmpty(list)) {
break; break;
} }
fillInfo(list,null); fillInfo(list);
bookAndAdviserRepository.save(list); bookAndAdviserRepository.save(list);
maxId = Long.valueOf(list.get(list.size() - 1).getBookId()); maxId = Long.valueOf(list.get(list.size() - 1).getBookId());
index += 1; index += 1;
...@@ -127,14 +125,11 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -127,14 +125,11 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
}); });
} }
private void fillInfo(List<ESBookAndAdviser> list, List<Long> bookIds){ private void fillInfo(List<ESBookAndAdviser> list){
Set<Long> searchBookIds = new HashSet<>(); Set<Long> searchBookIds = new HashSet<>();
Set<Long> channelIds = new HashSet<>(); Set<Long> channelIds = new HashSet<>();
Set<Long> adviserIds = new HashSet<>(); Set<Long> adviserIds = new HashSet<>();
List<Long> bookIds = new ArrayList<>();
Set<Long> sourceBookIds = new HashSet<>();
Set<Long> sourceChannelIds = new HashSet<>();
Set<Long> sourceAdviserIds = new HashSet<>();
List<BookIncomeQueryVo> bookIncomeQueryVos = new ArrayList<BookIncomeQueryVo>(); List<BookIncomeQueryVo> bookIncomeQueryVos = new ArrayList<BookIncomeQueryVo>();
for (ESBookAndAdviser esBookAndAdviser : list){ for (ESBookAndAdviser esBookAndAdviser : list){
if (esBookAndAdviser.getIsFundSupport()==1){//统计基金书数据 if (esBookAndAdviser.getIsFundSupport()==1){//统计基金书数据
...@@ -147,14 +142,14 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -147,14 +142,14 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
bookIncomeQueryVo.setAdviserId(Long.valueOf(esBookAndAdviser.getAdviserId())); bookIncomeQueryVo.setAdviserId(Long.valueOf(esBookAndAdviser.getAdviserId()));
bookIncomeQueryVos.add(bookIncomeQueryVo); bookIncomeQueryVos.add(bookIncomeQueryVo);
} }
sourceBookIds.add(Long.valueOf(esBookAndAdviser.getBookId())); bookIds.add(Long.valueOf(esBookAndAdviser.getBookId()));
sourceAdviserIds.add(Long.valueOf(esBookAndAdviser.getAdviserId()));
sourceChannelIds.add(Long.valueOf(esBookAndAdviser.getChannelId()));
} }
//书刊扫码量浏览量 //书刊扫码量浏览量
Map<String, BrowseCacheRecordDto> bookSvUvPvMap = browseRecordConsr.getBookSvUvPv(new ArrayList<>(adviserIds),new ArrayList<>(channelIds),new ArrayList<>(searchBookIds)); Map<String, BrowseCacheRecordDto> bookSvUvPvMap = browseRecordConsr.getBookSvUvPv(new ArrayList<>(adviserIds),new ArrayList<>(channelIds),new ArrayList<>(searchBookIds));
// 获取书刊累计收益(销售额) // 获取书刊累计收益(销售额)
Map<String, IncomeBackDto> bookIncomeMap = tradeConsr.getBookIncome(bookIncomeQueryVos, null); Map<String, IncomeBackDto> bookIncomeMap = tradeConsr.getBookIncome(bookIncomeQueryVos, null);
//整理后的标签
Map<Long, BookLabelTrimRelate> trimLabelMap = bookLabelBiz.mapBookTrimLabel(bookIds);
for (ESBookAndAdviser bookAndAdviser : list){ for (ESBookAndAdviser bookAndAdviser : list){
String key = bookAndAdviser.getBookId() + "-" + bookAndAdviser.getAdviserId() + "-" + bookAndAdviser.getChannelId(); String key = bookAndAdviser.getBookId() + "-" + bookAndAdviser.getAdviserId() + "-" + bookAndAdviser.getChannelId();
//统计基金书数据 //统计基金书数据
...@@ -192,6 +187,15 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -192,6 +187,15 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
} }
bookAndAdviser.setResourceCount(bookServeVOS.size()); bookAndAdviser.setResourceCount(bookServeVOS.size());
bookAndAdviser.setHasAnswer(hasAnswer); bookAndAdviser.setHasAnswer(hasAnswer);
//整理后的标签
BookLabelTrimRelate bookLabelTrimRelate = null;
if (!MapUtils.isEmpty(trimLabelMap) && trimLabelMap.containsKey(bookId)) {
bookLabelTrimRelate = trimLabelMap.get(bookId);
}
bookAndAdviser.setLabel1(null == bookLabelTrimRelate? "":bookLabelTrimRelate.getLabel1());
bookAndAdviser.setLabel2(null == bookLabelTrimRelate? "":bookLabelTrimRelate.getLabel2());
bookAndAdviser.setLabel3(null == bookLabelTrimRelate? "":bookLabelTrimRelate.getLabel3());
bookAndAdviser.setLabel4(null == bookLabelTrimRelate? "":bookLabelTrimRelate.getLabel4());
} }
} }
...@@ -204,7 +208,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -204,7 +208,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
try { try {
List<ESBookAndAdviser> list = bookDao.findBookAndAdviserByBookIds(bookIds); List<ESBookAndAdviser> list = bookDao.findBookAndAdviserByBookIds(bookIds);
filterBooks(list); filterBooks(list);
fillInfo(list,bookIds); fillInfo(list);
if (ListUtils.isEmpty(list)){ if (ListUtils.isEmpty(list)){
return; return;
} }
...@@ -464,21 +468,30 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz { ...@@ -464,21 +468,30 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
@Override @Override
public Page<ESBookAndAdviser> getESAdviserBooks4Answer(String grayStatus, String keyword, Long graLabelId, Long subLabelId, Long verLabelId, Integer currentPage, Integer numPerPage, List<Long> templetIds) { public Page<ESBookAndAdviser> getESAdviserBooks4Answer(BookSearchParamVO bookSearchParamVO) {
Integer currentPage = bookSearchParamVO.getCurrentPage() == null?0:bookSearchParamVO.getCurrentPage();
Integer numPerPage = bookSearchParamVO.getNumPerPage() == null?10:bookSearchParamVO.getNumPerPage();
String keyword = bookSearchParamVO.getKeyword();
String grayStatus = bookSearchParamVO.getGrayStatus();
String label1 = bookSearchParamVO.getLabel1();
String label2 = bookSearchParamVO.getLabel2();
String label3 = bookSearchParamVO.getLabel3();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery() BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("isBookDelete", 0)) .filter(QueryBuilders.termQuery("isBookDelete", 0))
.filter(QueryBuilders.termQuery("isBookAdviserDelete", 0)) .filter(QueryBuilders.termQuery("isBookAdviserDelete", 0))
.filter(ListUtils.isEmpty(templetIds) ? QueryBuilders.boolQuery() : QueryBuilders.termsQuery("templetId", templetIds)) .filter(QueryBuilders.termQuery("isAdviserBook", 1))
.filter(null == graLabelId ? QueryBuilders.boolQuery() : QueryBuilders.termQuery("graLabelId", graLabelId)) .filter(StringUtil.isEmpty(label1) ? QueryBuilders.boolQuery() : QueryBuilders.matchPhraseQuery("label1", label1))
.filter(null == subLabelId ? QueryBuilders.boolQuery() : QueryBuilders.termQuery("subLabelId", subLabelId)) .filter(StringUtil.isEmpty(label2) ? QueryBuilders.boolQuery() : QueryBuilders.matchPhraseQuery("label2", label2))
.filter(null == verLabelId ? QueryBuilders.boolQuery() : QueryBuilders.termQuery("verLabelId", verLabelId)); .filter(StringUtil.isEmpty(label3) ? QueryBuilders.boolQuery() : QueryBuilders.matchPhraseQuery("label3", label3));
if (!StringUtil.isEmpty(keyword)) {
BoolQueryBuilder should = QueryBuilders.boolQuery() BoolQueryBuilder should = QueryBuilders.boolQuery()
.should(StringUtil.isEmpty(keyword) ? QueryBuilders.boolQuery() : QueryBuilders.wildcardQuery("bookName", "*" + keyword + "*")) .should(QueryBuilders.wildcardQuery("bookName", "*" + keyword + "*"))
.should(StringUtil.isEmpty(keyword) ? QueryBuilders.boolQuery() : QueryBuilders.wildcardQuery("isbn", "*" + keyword + "*")); .should(QueryBuilders.wildcardQuery("isbn", "*" + keyword + "*"));
boolQueryBuilder.must(should);
}
// 审核通过之后屏蔽掉测试编辑的书刊 // 审核通过之后屏蔽掉测试编辑的书刊
BoolQueryBuilder adviserIdBuilder = getAdviserIdBuilder(grayStatus); BoolQueryBuilder adviserIdBuilder = getAdviserIdBuilder(grayStatus);
boolQueryBuilder.must(adviserIdBuilder); boolQueryBuilder.must(adviserIdBuilder);
boolQueryBuilder.must(should);
Sort sort = new Sort(Sort.Direction.DESC, "isFundSupport", "fundBookValue", "resourceCount", "isAdviserBook", "lastModifiedDate", "bookId"); Sort sort = new Sort(Sort.Direction.DESC, "isFundSupport", "fundBookValue", "resourceCount", "isAdviserBook", "lastModifiedDate", "bookId");
PageRequest pageRequest = new PageRequest(currentPage, numPerPage, sort); PageRequest pageRequest = new PageRequest(currentPage, numPerPage, sort);
Page<ESBookAndAdviser> search = bookAndAdviserRepository.search(boolQueryBuilder, pageRequest); Page<ESBookAndAdviser> search = bookAndAdviserRepository.search(boolQueryBuilder, pageRequest);
......
...@@ -176,4 +176,22 @@ public class ESBookAndAdviser { ...@@ -176,4 +176,22 @@ public class ESBookAndAdviser {
* 是否配有答案 * 是否配有答案
*/ */
private Integer hasAnswer; private Integer hasAnswer;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
/**
* 上下册
*/
private String label4;
} }
...@@ -393,4 +393,12 @@ public interface ResourcePageBiz { ...@@ -393,4 +393,12 @@ public interface ResourcePageBiz {
* * @param null * * @param null
*/ */
Map<Long, ResourceRecomManage> mapResourceRecomManage(List<Long> serveIds, String serveType, Integer sourceFrom); Map<Long, ResourceRecomManage> mapResourceRecomManage(List<Long> serveIds, String serveType, Integer sourceFrom);
/**
* 书下所有应用资源,含完整链接
* @author:zhuyajie
* @date:2021/7/27 14:06
* * @param null
*/
List<BookServeDTO> getBookAllServeIdsIncludeUrl(Long adviserId, Long bookId, Long channelId);
} }
...@@ -1966,6 +1966,23 @@ public class ResourcePageBizImpl implements ResourcePageBiz { ...@@ -1966,6 +1966,23 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return manageMap; return manageMap;
} }
@Override
public List<BookServeDTO> getBookAllServeIdsIncludeUrl(Long adviserId, Long bookId, Long channelId) {
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
if (null == accountSettingDto){
return new ArrayList<>();
}
List<BookServeDTO> list = resourcePageItemDao.getBookAllServeIds(adviserId, bookId, channelId);
if (ListUtils.isEmpty(list)) {
return list;
}
for (BookServeDTO bookServeDTO:list) {
String url = SendWeixinRequestTools.splitUrl(accountSettingDto, bookServeDTO.getUrl());
bookServeDTO.setUrl(url);
}
return list;
}
/** /**
* 热门课程 * 热门课程
* @author:zhuyajie * @author:zhuyajie
......
...@@ -114,4 +114,12 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{ ...@@ -114,4 +114,12 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{
* * @param null * * @param null
*/ */
List<Long> getAppIdsByPageId(Long resourcePageId); List<Long> getAppIdsByPageId(Long resourcePageId);
/**
* 书下所有资源
* @author:zhuyajie
* @date:2021/7/27 14:07
* * @param null
*/
List<BookServeDTO> getBookAllServeIds(Long adviserId, Long bookId, Long channelId);
} }
\ No newline at end of file
...@@ -113,4 +113,13 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple ...@@ -113,4 +113,13 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple
public List<Long> getAppIdsByPageId(Long resourcePageId) { public List<Long> getAppIdsByPageId(Long resourcePageId) {
return getSessionTemplate().selectList(getStatement("getAppIdsByPageId"), resourcePageId); return getSessionTemplate().selectList(getStatement("getAppIdsByPageId"), resourcePageId);
} }
@Override
public List<BookServeDTO> getBookAllServeIds(Long adviserId, Long bookId, Long channelId) {
Map<String ,Object> map = new HashMap<>();
map.put("adviserId", adviserId);
map.put("bookId", bookId);
map.put("channelId", channelId);
return getSessionTemplate().selectList(getStatement("getBookAllServeIds"), map);
}
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.book.dao.impl.BookLabelTrimDaoImpl">
<resultMap type="com.pcloud.book.book.entity.BookLabelTrim" id="BookLabelTrimMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="getById" resultMap="BookLabelTrimMap">
select
id, name, type, create_time
from book.book_label_trim
where id = #{id}
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.book_label_trim(name, type, create_time)
values (#{name}, #{type}, now())
</insert>
<!--通过主键修改数据-->
<update id="update">
update book.book_label_trim
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from book.book_label_trim where id = #{id}
</delete>
<select id="getBookLabelTrimList" parameterType="map" resultMap="BookLabelTrimMap">
SELECT
id, `name`, type, create_time
FROM
book.book_label_trim
WHERE 1=1
<if test="type != null">
AND type = #{type}
</if>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.book.dao.impl.BookLabelTrimRelateDaoImpl">
<resultMap type="com.pcloud.book.book.entity.BookLabelTrimRelate" id="BookLabelTrimRelateMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="bookId" column="book_id" jdbcType="INTEGER"/>
<result property="label1" column="label1" jdbcType="VARCHAR"/>
<result property="label2" column="label2" jdbcType="VARCHAR"/>
<result property="label3" column="label3" jdbcType="VARCHAR"/>
<result property="label4" column="label4" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="getById" resultMap="BookLabelTrimRelateMap">
select
id, book_id, label1, label2, label3, label4, create_time, update_time
from book.book_label_trim_relate
where id = #{id}
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.book_label_trim_relate(book_id, label1, label2, label3, label4, create_time, update_time)
values (#{bookId}, #{label1}, #{label2}, #{label3}, #{label4}, now(), now())
</insert>
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
insert into book.book_label_trim_relate(book_id, label1, label2, label3, label4, create_time, update_time)
values
<foreach collection="list" item="item" separator="," index="index">
(#{item.bookId}, #{item.label1}, #{item.label2}, #{item.label3}, #{item.label4}, now(), now())
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update book.book_label_trim_relate
<set>
<if test="bookId != null">
book_id = #{bookId},
</if>
<if test="label1 != null">
label1 = #{label1},
</if>
<if test="label2 != null">
label2 = #{label2},
</if>
<if test="label3 != null">
label3 = #{label3},
</if>
<if test="label4 != null">
label4 = #{label4},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from book.book_label_trim_relate where id = #{id}
</delete>
<select id="mapBookTrimLabel" resultMap="BookLabelTrimRelateMap" parameterType="map">
select
id, book_id, label1, label2, label3, label4
from book.book_label_trim_relate
where book_id IN
<foreach collection="bookIds" index="index" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
...@@ -299,4 +299,23 @@ ...@@ -299,4 +299,23 @@
resource_page_id = #{resourcePageId} resource_page_id = #{resourcePageId}
AND serve_type = "APP" AND serve_type = "APP"
</select> </select>
<select id="getBookAllServeIds" parameterType="map" resultType="com.pcloud.book.group.dto.BookServeDTO">
SELECT
i.serve_id serveId,
i.serve_type serveType,
i.link_url url,
i.type_code fromType
FROM
resource_page_item i
LEFT JOIN resource_page p ON i.resource_page_id = p.id
WHERE
i.serve_type IN ("APP", "PRODUCT")
AND p.book_id = #{bookId}
AND p.channel_id = #{channelId}
AND p.create_user = #{adviserId}
GROUP BY
i.serve_type,
i.serve_id
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment