Commit 979afa20 by 田超

Merge branch 'feature/addResourceNum' into 'master'

feat: [none] 新增字段资源数量

See merge request rays/pcloud-book!1173
parents 3b86b71b 7108ab1c
...@@ -85,6 +85,7 @@ import com.pcloud.book.book.tools.BookTools; ...@@ -85,6 +85,7 @@ import com.pcloud.book.book.tools.BookTools;
import com.pcloud.book.book.vo.BookInfo4ScanCount; import com.pcloud.book.book.vo.BookInfo4ScanCount;
import com.pcloud.book.book.vo.BookLabelVO; import com.pcloud.book.book.vo.BookLabelVO;
import com.pcloud.book.book.vo.BookQualifyVO; import com.pcloud.book.book.vo.BookQualifyVO;
import com.pcloud.book.book.vo.BookResourceNumDTO;
import com.pcloud.book.book.vo.BookSaleVO; import com.pcloud.book.book.vo.BookSaleVO;
import com.pcloud.book.book.vo.ListNoAuthBookParam; import com.pcloud.book.book.vo.ListNoAuthBookParam;
import com.pcloud.book.book.vo.ListNoAuthGroupBookParam; import com.pcloud.book.book.vo.ListNoAuthGroupBookParam;
...@@ -134,6 +135,7 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto; ...@@ -134,6 +135,7 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.qrcode.entity.QrcodeLabel; import com.pcloud.channelcenter.qrcode.entity.QrcodeLabel;
import com.pcloud.channelcenter.qrcode.entity.QrcodeScene; import com.pcloud.channelcenter.qrcode.entity.QrcodeScene;
import com.pcloud.channelcenter.qrcode.entity.QrcodeStyle; import com.pcloud.channelcenter.qrcode.entity.QrcodeStyle;
import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumRespDTO;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO; import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.dto.MessageDto; import com.pcloud.channelcenter.wechat.dto.MessageDto;
import com.pcloud.channelcenter.wechat.vo.BookServeVO; import com.pcloud.channelcenter.wechat.vo.BookServeVO;
...@@ -189,6 +191,7 @@ import java.util.concurrent.CompletableFuture; ...@@ -189,6 +191,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -3969,12 +3972,49 @@ public class BookBizImpl implements BookBiz { ...@@ -3969,12 +3972,49 @@ public class BookBizImpl implements BookBiz {
List<Long> adviserIds = requestVOS.stream().filter(Objects::nonNull).map(BookInfo4ScanCountRequestVO::getAdviserId).collect(Collectors.toList()); List<Long> adviserIds = requestVOS.stream().filter(Objects::nonNull).map(BookInfo4ScanCountRequestVO::getAdviserId).collect(Collectors.toList());
List<Long> bookIds = requestVOS.stream().filter(Objects::nonNull).map(BookInfo4ScanCountRequestVO::getBookId).collect(Collectors.toList()); List<Long> bookIds = requestVOS.stream().filter(Objects::nonNull).map(BookInfo4ScanCountRequestVO::getBookId).collect(Collectors.toList());
List<Long> channelIds = requestVOS.stream().filter(Objects::nonNull).map(BookInfo4ScanCountRequestVO::getChannelId).collect(Collectors.toList()); List<Long> channelIds = requestVOS.stream().filter(Objects::nonNull).map(BookInfo4ScanCountRequestVO::getChannelId).collect(Collectors.toList());
if (CollUtil.isEmpty(adviserIds) || CollUtil.isEmpty(bookIds) || CollUtil.isEmpty(channelIds)) return new ArrayList<>();
// ERP查询是否立项 // ERP查询是否立项
CompletableFuture<Map<String, ErpBookApprovalDTO>> isApprovalFuture = CompletableFuture.supplyAsync(() -> Optional.ofNullable(erpConsr.getIsApproval(adviserIds, channelIds, bookIds)).orElse(new HashMap<>())); CompletableFuture<Map<String, ErpBookApprovalDTO>> isApprovalFuture = CompletableFuture.supplyAsync(() -> Optional.ofNullable(erpConsr.getIsApproval(adviserIds, channelIds, bookIds)).orElse(new HashMap<>()));
// 查询图书信息 // 查询图书信息
CompletableFuture<List<BookInfo4ScanCount>> bookInfoFuture = CompletableFuture.supplyAsync(() -> Optional.ofNullable(bookAdviserDao.listBookInfo4ScanCount(adviserIds, channelIds, bookIds)).orElse(new ArrayList<>())); CompletableFuture<List<BookInfo4ScanCount>> bookInfoFuture = CompletableFuture.supplyAsync(() -> Optional.ofNullable(bookAdviserDao.listBookInfo4ScanCount(adviserIds, channelIds, bookIds)).orElse(new ArrayList<>()));
// 补充资源数量 - 平台端相关配置
Map<String, BookResourceNumDTO> pcloudResourceNumMap = new HashMap<>();
CompletableFuture<Void> pcloudResourceNumFuture = CompletableFuture.runAsync(() -> {
List<BookResourceNumDTO> list = rightsSettingBookRelationMapper.listReousrceNum4Book(adviserIds, channelIds, bookIds);
Map<String, BookResourceNumDTO> map = Optional.ofNullable(list).map(x -> x.stream().collect(
Collectors.toMap(book -> book.getBookId() + "-" + book.getAdviserId() + "-" + book.getChannelId(), Function.identity())))
.orElse(new HashMap<>());
pcloudResourceNumMap.putAll(map);
});
// 补充资源数量 - 编辑端相关配置 part1. 渠道获取数据
Map<String, AdviserBookResourceNumRespDTO> adviserResourceNum4ChannelMap = new HashMap<>();
CompletableFuture<Void> adviserResourceNum4ChannelFuture = CompletableFuture.runAsync(() -> {
List<AdviserBookResourceNumRespDTO> respDTOS = qrcodeSceneConsr.listResourceNum4AdviserBook(adviserIds, channelIds, bookIds);
Map<String, AdviserBookResourceNumRespDTO> map = Optional.ofNullable(respDTOS).map(x -> x.stream().collect(
Collectors.toMap(book -> book.getBookId() + "-" + book.getAdviserId() + "-" + book.getChannelId(), Function.identity())))
.orElse(new HashMap<>());
adviserResourceNum4ChannelMap.putAll(map);
});
// 补充资源数量 - 编辑端相关配置 part2. 图书获取数据
Map<String, BookResourceNumDTO> adviserResourceNum4BookMap = new HashMap<>();
CompletableFuture<Void> adviserResourceNum4BookFuture = CompletableFuture.runAsync(() -> {
List<BookResourceNumDTO> list = bookGroupServeDao.listResourceNum4AdviserBook(adviserIds, channelIds, bookIds);
Map<String, BookResourceNumDTO> map = Optional.ofNullable(list).map(x -> x.stream().collect(
Collectors.toMap(book -> book.getBookId() + "-" + book.getAdviserId() + "-" + book.getChannelId(), Function.identity())))
.orElse(new HashMap<>());
adviserResourceNum4BookMap.putAll(map);
});
// 资源数量任务组
CompletableFuture<Void> resourceNumGroupFuture = CompletableFuture.allOf(pcloudResourceNumFuture, adviserResourceNum4ChannelFuture, adviserResourceNum4BookFuture);
// 等待结果返回 // 等待结果返回
try { try {
List<BookInfo4ScanCount> bookInfo4ScanCounts = bookInfoFuture.get(); List<BookInfo4ScanCount> bookInfo4ScanCounts = bookInfoFuture.get();
...@@ -4016,7 +4056,7 @@ public class BookBizImpl implements BookBiz { ...@@ -4016,7 +4056,7 @@ public class BookBizImpl implements BookBiz {
}); });
// 等待所有任务完成 // 等待所有任务完成
CompletableFuture.allOf(isApprovalFuture, bookLabelIdFuture, centerLabelIdFuture, templateFuture).get(); CompletableFuture.allOf(isApprovalFuture, bookLabelIdFuture, centerLabelIdFuture, templateFuture, resourceNumGroupFuture).get();
Map<String, ErpBookApprovalDTO> isApprovalDTOMap = isApprovalFuture.get(); Map<String, ErpBookApprovalDTO> isApprovalDTOMap = isApprovalFuture.get();
...@@ -4041,10 +4081,17 @@ public class BookBizImpl implements BookBiz { ...@@ -4041,10 +4081,17 @@ public class BookBizImpl implements BookBiz {
// 填充 是否立项 // 填充 是否立项
book.setIsApproval(0); book.setIsApproval(0);
ErpBookApprovalDTO erpBookApprovalDTO = isApprovalDTOMap.get(book.getBookId() + "-" + book.getAdviserId() + "-" + book.getChannelId()); String key = book.getBookId() + "-" + book.getAdviserId() + "-" + book.getChannelId();
ErpBookApprovalDTO erpBookApprovalDTO = isApprovalDTOMap.get(key);
if (Objects.isNull(erpBookApprovalDTO) || Objects.isNull(erpBookApprovalDTO.getIsApproval())) { if (Objects.isNull(erpBookApprovalDTO) || Objects.isNull(erpBookApprovalDTO.getIsApproval())) {
book.setIsApproval(1); book.setIsApproval(1);
} }
// 配置资源数 = 平台端配置资源数 + 渠道来源的编辑端配置资源数 + 图书来源的编辑端配置资源数
book.setResourceNum(
Optional.ofNullable(pcloudResourceNumMap).map(x -> x.get(key)).map(BookResourceNumDTO::getResourceNum).orElse(0) +
Optional.ofNullable(adviserResourceNum4ChannelMap).map(x -> x.get(key)).map(AdviserBookResourceNumRespDTO::getResourceNum).orElse(0) +
Optional.ofNullable(adviserResourceNum4BookMap).map(x -> x.get(key)).map(BookResourceNumDTO::getResourceNum).orElse(0)
);
} }
return bookInfo4ScanCounts; return bookInfo4ScanCounts;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -48,4 +48,6 @@ public class BookInfo4ScanCount { ...@@ -48,4 +48,6 @@ public class BookInfo4ScanCount {
private Integer isApproval; private Integer isApproval;
private Integer resourceNum;
} }
package com.pcloud.book.book.vo;
import lombok.Data;
@Data
public class BookResourceNumDTO {
private Long adviserId;
private Long channelId;
private Long bookId;
private Integer resourceNum;
}
...@@ -13,6 +13,8 @@ import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrAskVO; ...@@ -13,6 +13,8 @@ import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrAskVO;
import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrVO; import com.pcloud.channelcenter.qrcode.vo.BookAssocLastQrVO;
import com.pcloud.channelcenter.qrcode.vo.BookAssocQRcountRequestVO; import com.pcloud.channelcenter.qrcode.vo.BookAssocQRcountRequestVO;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumReqDTO;
import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumRespDTO;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO; import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.dto.ListIsInBookParam; import com.pcloud.channelcenter.wechat.dto.ListIsInBookParam;
import com.pcloud.channelcenter.wechat.service.AccountSettingService; import com.pcloud.channelcenter.wechat.service.AccountSettingService;
...@@ -450,4 +452,19 @@ public class QrcodeSceneConsr { ...@@ -450,4 +452,19 @@ public class QrcodeSceneConsr {
} }
return null; return null;
} }
@ParamLog("获取图书下的资源数量")
public List<AdviserBookResourceNumRespDTO> listResourceNum4AdviserBook(List<Long> adviserIds, List<Long> channelIds, List<Long> bookIds) {
List<AdviserBookResourceNumRespDTO> list = new ArrayList<>();
try {
AdviserBookResourceNumReqDTO reqDTO = new AdviserBookResourceNumReqDTO();
reqDTO.setAdviserIds(adviserIds);
reqDTO.setBookIds(bookIds);
reqDTO.setChannelIds(channelIds);
list = ResponseHandleUtil.parseList(messageService.listResourceNum4AdviserBook(reqDTO), AdviserBookResourceNumRespDTO.class);
} catch (Exception e) {
LOGGER.error("【获取图书下的资源数量】 请求失败,<ERROR>.[listResourceNum4AdviserBook]:{}", e.getMessage(), e);
}
return list;
}
} }
package com.pcloud.book.group.dao; package com.pcloud.book.group.dao;
import com.pcloud.book.book.vo.BookResourceNumDTO;
import com.pcloud.book.group.dto.BookGroupCountDTO; import com.pcloud.book.group.dto.BookGroupCountDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO; import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.BookGroupApp; import com.pcloud.book.group.entity.BookGroupApp;
...@@ -87,4 +88,6 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> { ...@@ -87,4 +88,6 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> {
* * @param null * * @param null
*/ */
List<BookGroupServe> getServeListByBook(Long bookId, Long channelId, Long adviserId); List<BookGroupServe> getServeListByBook(Long bookId, Long channelId, Long adviserId);
List<BookResourceNumDTO> listResourceNum4AdviserBook(List<Long> adviserIds, List<Long> channelIds, List<Long> bookIds);
} }
package com.pcloud.book.group.dao.impl; package com.pcloud.book.group.dao.impl;
import cn.hutool.core.map.MapUtil;
import com.pcloud.book.book.vo.BookResourceNumDTO;
import com.pcloud.book.group.dao.BookGroupServeDao; import com.pcloud.book.group.dao.BookGroupServeDao;
import com.pcloud.book.group.dto.BookGroupCountDTO; import com.pcloud.book.group.dto.BookGroupCountDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO; import com.pcloud.book.group.dto.BookGroupServeCountDTO;
...@@ -160,4 +162,12 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement ...@@ -160,4 +162,12 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
map.put("channelId", channelId); map.put("channelId", channelId);
return getSessionTemplate().selectList(getStatement("getServeListByBook"), map); return getSessionTemplate().selectList(getStatement("getServeListByBook"), map);
} }
@Override
public List<BookResourceNumDTO> listResourceNum4AdviserBook(List<Long> adviserIds, List<Long> channelIds, List<Long> bookIds) {
HashMap<String, List<Long>> param = MapUtil.of("adviserIds", adviserIds);
param.put("channelIds", channelIds);
param.put("bookIds", bookIds);
return getSessionTemplate().selectList(getStatement("listResourceNum4AdviserBook"), param);
}
} }
package com.pcloud.book.rightsSetting.mapper; package com.pcloud.book.rightsSetting.mapper;
import com.pcloud.book.book.vo.BookResourceNumDTO;
import com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation; import com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -29,4 +31,8 @@ public interface RightsSettingBookRelationMapper { ...@@ -29,4 +31,8 @@ public interface RightsSettingBookRelationMapper {
List<RightsSettingBookRelation> selectBookByRithsSettingId(Long rightsSettingId); List<RightsSettingBookRelation> selectBookByRithsSettingId(Long rightsSettingId);
List<Long> getAllBookIds(); List<Long> getAllBookIds();
List<BookResourceNumDTO> listReousrceNum4Book(@Param("adviserIds") List<Long> adviserIds,
@Param("channelIds") List<Long> channelIds,
@Param("bookIds") List<Long> bookIds);
} }
\ No newline at end of file
...@@ -286,4 +286,26 @@ ...@@ -286,4 +286,26 @@
s.id s.id
</select> </select>
<select id="listResourceNum4AdviserBook" parameterType="map" resultType="com.pcloud.book.book.vo.BookResourceNumDTO">
SELECT count(concat(s.serve_id, s.serve_type)) resourceNum,
g.book_id bookId,
g.channel_id channelId,
g.create_user adviserId
FROM book_group_serve s
LEFT JOIN book_group g ON s.book_group_id = g.id
WHERE g.book_id in
<foreach collection="bookIds" separator="," item="item" close=")" open="(">
${item}
</foreach>
AND g.channel_id in
<foreach collection="channelIds" separator="," item="item" close=")" open="(">
${item}
</foreach>
AND g.create_user in
<foreach collection="adviserIds" separator="," item="item" close=")" open="(">
${item}
</foreach>
GROUP BY bookId, channelId, adviserId
</select>
</mapper> </mapper>
...@@ -214,4 +214,23 @@ ...@@ -214,4 +214,23 @@
where rights_setting_id = #{_parameter} where rights_setting_id = #{_parameter}
group by r.book_id group by r.book_id
</select> </select>
<select id="listReousrceNum4Book" resultType="com.pcloud.book.book.vo.BookResourceNumDTO">
select count(a.id) resourceNum, b.adviser_id adviserId, b.book_id bookId, b.channel_id channelId
from rights_setting_item a
left join rights_setting_book_relation b on a.rights_setting_id = b.rights_setting_id
where book_id in
<foreach collection="bookIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and adviser_id in
<foreach collection="adviserIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and channel_id in
<foreach collection="channelIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
group by b.adviser_id, b.book_id, b.channel_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