Commit f4b80b81 by 郑永强

feat:[1003270] ERP关联RAYS书刊,非现代纸书配置资源数取值优化ERP关联RAYS书刊,非现代纸书配置资源数取值优化

parent 447cf109
...@@ -15,6 +15,7 @@ import com.pcloud.book.book.vo.QrCodeVO; ...@@ -15,6 +15,7 @@ import com.pcloud.book.book.vo.QrCodeVO;
import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto; import com.pcloud.book.book.vo.request.UpdateBookRobotProcessDto;
import com.pcloud.book.group.dto.BookGroupDTO; import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO; import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto; import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
...@@ -894,7 +895,17 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -894,7 +895,17 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
List<QrCodeVO> qrCodeVOS = new ArrayList<>(); List<QrCodeVO> qrCodeVOS = new ArrayList<>();
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId, channelId, adviserId); BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(bookId, channelId, adviserId);
if (null != bookGroupDTO) { if (null != bookGroupDTO) {
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount = bookGroupBiz.mapBookGroupServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId)); Map<String, BookGroupServeCountDTO> mapBookGroupServeCount;
Map<String, BookGroupServeCountDTO> mapBookGroupRobotServeCount = null;
if(JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(bookGroupDTO.getJoinGroupType())){
mapBookGroupServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId), JoinGroupTypeEnum.GROUP_QRCODE.getCode());
} else {
mapBookGroupServeCount = bookGroupBiz.mapBookGroupServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId));
// 获取 1V1 关键词回复数量
if(JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
mapBookGroupRobotServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId), JoinGroupTypeEnum.ROBOT.getCode());
}
}
QrCodeVO qrCodeVO = new QrCodeVO(); QrCodeVO qrCodeVO = new QrCodeVO();
qrCodeVO.setQrCodeName(bookGroupDTO.getGroupQrcodeName()); qrCodeVO.setQrCodeName(bookGroupDTO.getGroupQrcodeName());
qrCodeVO.setQrCodeUrl(bookGroupDTO.getGroupQrcodeUrl()); qrCodeVO.setQrCodeUrl(bookGroupDTO.getGroupQrcodeUrl());
...@@ -903,6 +914,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -903,6 +914,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get("" + bookId + "_" + channelId + "_" + adviserId); BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get("" + bookId + "_" + channelId + "_" + adviserId);
qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount()); qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount());
} }
if(mapBookGroupRobotServeCount!=null && !mapBookGroupRobotServeCount.isEmpty()){
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupRobotServeCount.get("" + bookId + "_" + channelId + "_" + adviserId);
qrCodeVO.setServeCount(qrCodeVO.getServeCount() + bookGroupServeCountDTO.getServeCount());
}
qrCodeVOS.add(qrCodeVO); qrCodeVOS.add(qrCodeVO);
} }
List<QrcodeSceneDto> qrcodeSceneDtos = qrcodeSceneConsr.getQrCodeList(bookId, adviserId, channelId); List<QrcodeSceneDto> qrcodeSceneDtos = qrcodeSceneConsr.getQrCodeList(bookId, adviserId, channelId);
...@@ -935,31 +950,81 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -935,31 +950,81 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
} }
Map<String, QrcodeMessageDTO> mapQrcodeMessage = channelConsr.mapResourceCount(adviserIds, bookIds, channelIds); Map<String, QrcodeMessageDTO> mapQrcodeMessage = channelConsr.mapResourceCount(adviserIds, bookIds, channelIds);
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount = bookGroupBiz.mapBookGroupServeCount(adviserIds, bookIds, channelIds); Map<String, BookGroupServeCountDTO> mapBookGroupServeCount = bookGroupBiz.mapBookGroupServeCount(adviserIds, bookIds, channelIds);
Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(adviserIds, bookIds, channelIds, JoinGroupTypeEnum.GROUP_QRCODE.getCode());
Map<String, BookGroupServeCountDTO> mapBookGroupRobotServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(adviserIds, bookIds, channelIds, JoinGroupTypeEnum.ROBOT.getCode());
if(mapQrcodeMessage == null || mapQrcodeMessage.isEmpty()){ if(mapQrcodeMessage == null || mapQrcodeMessage.isEmpty()){
mapQrcodeMessage = new HashMap<>(); mapQrcodeMessage = new HashMap<>();
} }
if(mapBookGroupServeCount == null || mapBookGroupServeCount.isEmpty()){
mapBookGroupServeCount = new HashMap<>();
}
if(mapBookGroupQrcodeServeCount == null || mapBookGroupQrcodeServeCount.isEmpty()){
mapBookGroupQrcodeServeCount = new HashMap<>();
}
if(mapBookGroupRobotServeCount == null || mapBookGroupRobotServeCount.isEmpty()){
mapBookGroupRobotServeCount = new HashMap<>();
}
List<String> bookChannelAdviserIds = mapQrcodeMessage.keySet().stream().collect(Collectors.toList());
bookChannelAdviserIds.addAll(mapBookGroupServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds.addAll(mapBookGroupQrcodeServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds.addAll(mapBookGroupRobotServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds = bookChannelAdviserIds.stream().distinct().collect(Collectors.toList());
BookResourceStatisticsDTO bookResourceStatisticsDTO; BookResourceStatisticsDTO bookResourceStatisticsDTO;
for (QrcodeMessageDTO qrcodeMessageDTO : mapQrcodeMessage.values()) { for (String bookChannelAdviserId : bookChannelAdviserIds) {
// mapBookGroupServeCount 包含了(客服机器人、1v1、小睿)
// mapBookGroupRobotServeCount 查的是1v1
// 他们是同一个码,所以只能算一个码数量
boolean added = false;
bookResourceStatisticsDTO = new BookResourceStatisticsDTO(); bookResourceStatisticsDTO = new BookResourceStatisticsDTO();
BeanUtils.copyProperties(qrcodeMessageDTO, bookResourceStatisticsDTO); QrcodeMessageDTO qrcodeMessageDTO = mapQrcodeMessage.get(bookChannelAdviserId);
mapBookResourceStatistics.put(bookResourceStatisticsDTO.getBookChannelAdviserId(), bookResourceStatisticsDTO); BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get(bookChannelAdviserId);
if(mapBookGroupServeCount == null || mapBookGroupServeCount.isEmpty()){ BookGroupServeCountDTO bookGroupQrcodeServeCountDTO = mapBookGroupQrcodeServeCount.get(bookChannelAdviserId);
continue; BookGroupServeCountDTO bookGroupRobotServeCountDTO = mapBookGroupRobotServeCount.get(bookChannelAdviserId);
if(qrcodeMessageDTO != null){
if(StringUtil.isEmpty(bookResourceStatisticsDTO.getBookChannelAdviserId())){
BeanUtils.copyProperties(qrcodeMessageDTO, bookResourceStatisticsDTO);
bookResourceStatisticsDTO.setQrcodeCount(0);
bookResourceStatisticsDTO.setServeCount(0);
}
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + qrcodeMessageDTO.getServeCount());
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + qrcodeMessageDTO.getQrcodeCount());
} }
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get(bookResourceStatisticsDTO.getBookChannelAdviserId()); if(bookGroupServeCountDTO != null){
if(bookGroupServeCountDTO == null){ if(StringUtil.isEmpty(bookResourceStatisticsDTO.getBookChannelAdviserId())){
continue; BeanUtils.copyProperties(bookGroupServeCountDTO, bookResourceStatisticsDTO);
bookResourceStatisticsDTO.setQrcodeCount(0);
bookResourceStatisticsDTO.setServeCount(0);
}
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + bookGroupServeCountDTO.getServeCount());
if(!added){
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + bookGroupServeCountDTO.getQrcodeCount());
added = true;
}
} }
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + bookGroupServeCountDTO.getServeCount()); if(bookGroupQrcodeServeCountDTO != null){
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + bookGroupServeCountDTO.getQrcodeCount()); if(StringUtil.isEmpty(bookResourceStatisticsDTO.getBookChannelAdviserId())){
} BeanUtils.copyProperties(bookGroupQrcodeServeCountDTO, bookResourceStatisticsDTO);
for(BookGroupServeCountDTO bookGroupServeCountDTO : mapBookGroupServeCount.values()){ bookResourceStatisticsDTO.setQrcodeCount(0);
if(mapBookResourceStatistics.containsKey(bookGroupServeCountDTO.getBookChannelAdviserId())){ bookResourceStatisticsDTO.setServeCount(0);
continue; }
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + bookGroupQrcodeServeCountDTO.getServeCount());
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + bookGroupQrcodeServeCountDTO.getQrcodeCount());
} }
bookResourceStatisticsDTO = new BookResourceStatisticsDTO(); if(bookGroupRobotServeCountDTO != null){
BeanUtils.copyProperties(bookGroupServeCountDTO, bookResourceStatisticsDTO); if(StringUtil.isEmpty(bookResourceStatisticsDTO.getBookChannelAdviserId())){
mapBookResourceStatistics.put(bookResourceStatisticsDTO.getBookChannelAdviserId(), bookResourceStatisticsDTO); BeanUtils.copyProperties(bookGroupRobotServeCountDTO, bookResourceStatisticsDTO);
bookResourceStatisticsDTO.setQrcodeCount(0);
bookResourceStatisticsDTO.setServeCount(0);
}
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + bookGroupRobotServeCountDTO.getServeCount());
if(!added) {
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + bookGroupRobotServeCountDTO.getQrcodeCount());
added = true;
}
}
mapBookResourceStatistics.put(bookChannelAdviserId, bookResourceStatisticsDTO);
} }
return mapBookResourceStatistics; return mapBookResourceStatistics;
} }
......
...@@ -907,4 +907,14 @@ public interface BookGroupBiz { ...@@ -907,4 +907,14 @@ public interface BookGroupBiz {
* @return * @return
*/ */
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds); Map<String, BookGroupServeCountDTO> mapBookGroupServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds);
/**
* 批量获取书下的资源数
* @param adviserIds
* @param bookIds
* @param channelIds
* @return
*/
Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds, Integer groupType);
} }
...@@ -5257,4 +5257,12 @@ public class BookGroupBizImpl implements BookGroupBiz { ...@@ -5257,4 +5257,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
} }
return bookGroupServeDao.mapBookGroupServeCount(adviserIds, bookIds, channelIds); return bookGroupServeDao.mapBookGroupServeCount(adviserIds, bookIds, channelIds);
} }
@Override
public Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds, Integer joinGroupType){
if(CollectionUtils.isEmpty(adviserIds) || CollectionUtils.isEmpty(bookIds) || CollectionUtils.isEmpty(channelIds)){
throw new ChannelBizException(ChannelBizException.FILED_NULL, "adviserIds、bookIds、channelIds 参数为空!");
}
return bookGroupServeDao.mapBookGroupQrcodeServeCount(adviserIds, bookIds, channelIds, joinGroupType);
}
} }
...@@ -70,4 +70,14 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> { ...@@ -70,4 +70,14 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> {
* @return * @return
*/ */
Map<String, BookGroupServeCountDTO> mapBookGroupServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds); Map<String, BookGroupServeCountDTO> mapBookGroupServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds);
/**
* 批量获取书下的资源数
* @param adviserIds
* @param bookIds
* @param channelIds
* @return
*/
Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds, Integer joinGroupType);
} }
...@@ -114,4 +114,14 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement ...@@ -114,4 +114,14 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
map.put("channelIds", channelIds); map.put("channelIds", channelIds);
return getSessionTemplate().selectMap(getStatement("mapBookGroupServeCount"), map, "bookChannelAdviserId"); return getSessionTemplate().selectMap(getStatement("mapBookGroupServeCount"), map, "bookChannelAdviserId");
} }
@Override
public Map<String, BookGroupServeCountDTO> mapBookGroupQrcodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds, Integer joinGroupType) {
Map<String,Object> map = new HashMap<>();
map.put("adviserIds", adviserIds);
map.put("bookIds", bookIds);
map.put("channelIds", channelIds);
map.put("joinGroupType", joinGroupType);
return getSessionTemplate().selectMap(getStatement("mapBookGroupQrcodeServeCount"), map, "bookChannelAdviserId");
}
} }
...@@ -210,6 +210,7 @@ ...@@ -210,6 +210,7 @@
GROUP BY g.book_id,g.create_user,g.channel_id GROUP BY g.book_id,g.create_user,g.channel_id
</select> </select>
<!--客服机器人、1v1、小睿的资源数-->
<select id="mapBookGroupServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO"> <select id="mapBookGroupServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT SELECT
CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId, COUNT(bgs.id) serveCount, CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId, COUNT(bgs.id) serveCount,
...@@ -229,6 +230,34 @@ ...@@ -229,6 +230,34 @@
<foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")"> <foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")">
${adviserId} ${adviserId}
</foreach> </foreach>
AND bg.join_group_type IN (2,3,4)
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
<!--社群资源数-->
<select id="mapBookGroupQrcodeServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId,COUNT(DISTINCT k.id) serveCount,
bg.book_id bookId,bg.create_user adviserId,bg.channel_id channelId,COUNT(DISTINCT bg.group_qrcode_url) qrcodeCount
FROM
book_group bg
LEFT JOIN book_keyword bk ON bg.id=bk.book_group_id AND bk.is_delete = 0
LEFT JOIN keyword k ON bk.keyword_id = k.id AND k.is_delete = 0
WHERE
bg.is_delete = 0
AND bg.join_group_type = #{joinGroupType}
AND bg.book_id IN
<foreach collection="bookIds" item="bookId" separator="," open="(" close=")">
${bookId}
</foreach>
AND bg.channel_id IN
<foreach collection="channelIds" item="channelId" separator="," open="(" close=")">
${channelId}
</foreach>
AND bg.create_user IN
<foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")">
${adviserId}
</foreach>
GROUP BY bg.book_id,bg.create_user,bg.channel_id GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select> </select>
</mapper> </mapper>
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