Commit da8f499a by 朱亚洁

feat:[1006197]资源上书查询

parent f80070cc
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.applet.dto.ThirdResourceRecordDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
......@@ -47,4 +48,24 @@ public interface AppletThirdResourcesBiz {
*/
PageBeanNew<AppletThirdResources> getThirdResourcesByGradeLabel4ResourcePage(Long gradeLabelId, Integer currentPage,
Integer numPerPage);
/**
* @Description 根据编号查第三方资源
* @Author zhuyajie
* @Date 17:59 2021/12/14
**/
AppletThirdResourcesDTO getThirdResourceByNumber(String number);
/**
* @Description 第三方资源上书情况
* @Author zhuyajie
* @Date 17:56 2021/12/14
**/
PageBeanNew<ResourceOnBookDTO> listThirdResourceOnBook(Integer currentPage, Integer numPerPage, Long thirdResourceId);
/**
* @Description 导出-第三方资源上书情况
* @Author zhuyajie
* @Date 19:42 2021/12/14
**/
void exportThirdResourceOnBook(Long thirdResourceId,Long partyId);
}
package com.pcloud.book.applet.biz.impl;
import com.alibaba.fastjson.JSONObject;
import com.pcloud.book.applet.biz.AppletResourceApplyBiz;
import com.pcloud.book.applet.biz.AppletThirdResourcesBiz;
import com.pcloud.book.applet.contants.AppletConstants;
......@@ -12,6 +13,13 @@ import com.pcloud.book.applet.dto.AddResourceApplyDTO;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.common.ExportConsr;
import com.pcloud.book.consumer.data.DataConsr;
import com.pcloud.book.consumer.message.MessageConsr;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.applet.dto.ThirdResourceRecordDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
......@@ -23,15 +31,22 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.group.biz.BizMaterialBiz;
import com.pcloud.book.group.constant.ResourcePageConstants;
import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.enums.UseTypeEnum;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.data.domain.vo.CalQrcodeTargetVO;
import com.pcloud.readercenter.wechat.entity.WechatUser;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
......@@ -48,6 +63,7 @@ import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -73,6 +89,18 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
private AppletThirdResourcesPicMapper appletThirdResourcesPicMapper;
@Autowired
private AppletResourceApplyBiz appletResourceApplyBiz;
@Autowired
private ResourcePageItemDao resourcePageItemDao;
@Autowired
private BookBiz bookBiz;
@Autowired
private DataConsr dataConsr;
@Autowired
private ExportConsr exportConsr;
@Autowired
private MessageConsr messageConsr;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Override
public PageBeanNew<AppletThirdResourcesDTO> getListThirdResourcesAnalysis(String keyValue, String source,
......@@ -466,4 +494,145 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
return new PageBeanNew<>(currentPage, numPerPage, idPageBean.getTotalCount(), thirdResources);
}
@Override
public AppletThirdResourcesDTO getThirdResourceByNumber(String number) {
if (StringUtil.isEmpty(number)) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
AppletThirdResources resources = thirdResourcesDao.getThirdResourceByNumber(number);
if (null == resources) {
return new AppletThirdResourcesDTO();
}
AppletThirdResourcesDTO appletThirdResourcesDTO = BeanUtil.copyProperties(resources, AppletThirdResourcesDTO.class);
return appletThirdResourcesDTO;
}
@Override
public PageBeanNew<ResourceOnBookDTO> listThirdResourceOnBook(Integer currentPage, Integer numPerPage, Long thirdResourceId) {
if (null == currentPage || null == numPerPage || null == thirdResourceId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("serveId", thirdResourceId);
paramMap.put("serveType", ResourcePageConstants.ServeTypeEnum.THIRD_RESOURCE.getValue());
PageBeanNew<ResourceOnBookDTO> pageBeanNew = resourcePageItemDao.listPageNew(new PageParam(currentPage,numPerPage),paramMap,"listResourceOnBook");
if (ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage,numPerPage,pageBeanNew.getTotalCount(),new ArrayList<>());
}
this.fillInfo4OnBook(pageBeanNew.getRecordList(), thirdResourceId);
return pageBeanNew;
}
@Override
public void exportThirdResourceOnBook(Long thirdResourceId, Long partyId) {
if (null == thirdResourceId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
ThreadPoolUtils.EXPORT_THREAD_POOL.execute(()->{
AppletThirdResources thirdResources = thirdResourcesDao.getByResourcesId(thirdResourceId);
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("serveId", thirdResourceId);
paramMap.put("serveType", ResourcePageConstants.ServeTypeEnum.THIRD_RESOURCE.getValue());
List<ResourceOnBookDTO> list = resourcePageItemDao.listResourceOnBook(paramMap);
if (ListUtils.isEmpty(list)) {
return;
}
this.fillInfo4OnBook(list, thirdResourceId);
List<Object[]> excelDatas = new ArrayList<>();
String[] rowsName = {"二维码ID","二维码名称", "书刊ID", "书刊名称", "isbn", "编辑名称", "出版社名称", "二维码扫码量", "二维码读者量","二维码浏览量","点击量","点击人数"};
for (ResourceOnBookDTO vo : list) {
Object[] objs = new Object[rowsName.length];
objs[0] = vo.getSceneId();
objs[1] = vo.getSceneName();
objs[2] = vo.getBookId();
objs[3] = vo.getBookName();
objs[4] = vo.getIsbn();
objs[5] = vo.getAdviserName();
objs[6] = vo.getAgentName();
objs[7] = vo.getScanNum();
objs[8] = vo.getReaderNum();
objs[9] = vo.getBrowseNum();
objs[10] = vo.getResourceClickNum();
objs[11] = vo.getResourceClickUserNum();
excelDatas.add(objs);
}
String title = thirdResources.getName()+"-第三方资源上书明细";
String fileUrl = exportConsr.exportExcel(title, rowsName, excelDatas);
if (!StringUtil.isEmpty(fileUrl)) {
String letterType = "qrcode_download";
String fileName = title + DateUtils.today();
JSONObject content = new JSONObject();
content.put("commitTime", DateUtils.formatDate(new Date()));
content.put("type",title);
messageConsr.sendLetter(0L, partyId, content.toJSONString(), SystemCode.pcloud.code, letterType, fileUrl, fileName);
}
});
}
@ParamLog("填充数据")
private void fillInfo4OnBook(List<ResourceOnBookDTO> list, Long thirdResourceId) {
if (ListUtils.isEmpty(list)) {
return;
}
List<Long> bookIds = new ArrayList<>();
List<Long> channelIds = new ArrayList<>();
List<Long> sceneIds = new ArrayList<>();
List<Long> adviserIds = new ArrayList<>();
for (ResourceOnBookDTO vo:list) {
sceneIds.add(vo.getSceneId());
if (null != vo.getBookId() && !bookIds.contains(vo.getBookId())) {
bookIds.add(vo.getBookId());
}
if (null != vo.getAdviserId() && !adviserIds.contains(vo.getAdviserId())) {
adviserIds.add(vo.getAdviserId());
}
if (null != vo.getChannelId() && !channelIds.contains(vo.getChannelId())) {
channelIds.add(vo.getChannelId());
}
}
//二维码信息
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = qrcodeSceneConsr.listBaseInfoByIds(sceneIds);
//书刊信息
Map<Long, BookDto> bookDtoMap = bookBiz.listBaseByIds(bookIds);
//编辑信息
Map<Long, AdviserBaseInfoDto> adviserDtoMap = adviserConsr.getAdviserId2AdviserInfoDtoMap(adviserIds);
//二维码扫码人数浏览人数
Map<String, CalQrcodeTargetVO> qrcodeStatisMap = dataConsr.mapQrcodeStatisByBookIds(bookIds, adviserIds, channelIds, sceneIds);
//资源点击量点击人数
Map<String, List<PvuvDTO>> clickMap = new HashMap<>();
List<PvuvDTO> pvuvDTOS = thirdResourcesClickDao.mapPVUV4BookByResourceId(thirdResourceId,DataRecordTypeEnum.click.code);
if (!ListUtils.isEmpty(pvuvDTOS)) {
clickMap = pvuvDTOS.stream().collect(Collectors.groupingBy(vo->StrUtil.join("-", vo.getBookId(), vo.getAdviserId(), vo.getChannelId())));
}
for (ResourceOnBookDTO vo:list) {
if (!MapUtils.isEmpty(qrcodeSceneDtoMap) && qrcodeSceneDtoMap.containsKey(vo.getSceneId())) {
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(vo.getSceneId());
vo.setSceneName(qrcodeSceneDto.getSceneName());
}
if (!MapUtils.isEmpty(bookDtoMap) && null != vo.getBookId() && bookDtoMap.containsKey(vo.getBookId())) {
BookDto bookDto = bookDtoMap.get(vo.getBookId());
vo.setBookName(bookDto.getBookName());
vo.setIsbn(bookDto.getIsbn());
}
if (!MapUtils.isEmpty(adviserDtoMap) && null != vo.getAdviserId() && adviserDtoMap.containsKey(vo.getAdviserId())) {
AdviserBaseInfoDto adviserBaseInfoDto = adviserDtoMap.get(vo.getAdviserId());
vo.setAdviserName(adviserBaseInfoDto.getPartyName());
vo.setAgentName(adviserBaseInfoDto.getAgentName());
}
String qrcodeKey = StrUtil.join("-", vo.getBookId(), vo.getAdviserId(), vo.getChannelId(), vo.getSceneId());
if (!MapUtils.isEmpty(qrcodeStatisMap) && qrcodeStatisMap.containsKey(qrcodeKey)) {
CalQrcodeTargetVO statisDTO = qrcodeStatisMap.get(qrcodeKey);
vo.setScanNum(statisDTO.getSca());
vo.setBrowseNum(statisDTO.getPva());
vo.setReaderNum(statisDTO.getUa());
}
String resourceKey = StrUtil.join("-", vo.getBookId(), vo.getAdviserId(), vo.getChannelId());
if (!MapUtils.isEmpty(clickMap) && clickMap.containsKey(resourceKey)) {
List<PvuvDTO> pvuv = clickMap.get(resourceKey);
vo.setResourceClickNum(pvuv.get(0).getPv());
vo.setResourceClickUserNum(pvuv.get(0).getUv());
}
}
}
}
......@@ -16,5 +16,12 @@ public interface AppletThirdResourcesClickDao extends BaseDao<AppletThirdResourc
* 趋势图数据
*/
List<AppletChartDateDTO> mapPVUVByMonth(Integer recordType, Long newsId);
/**
* @Description 资源上书数据统计
* @Author zhuyajie
* @Date 19:21 2021/12/14
**/
List<PvuvDTO> mapPVUV4BookByResourceId(Long thirdResourceId, Integer recordType);
}
......@@ -21,4 +21,6 @@ public interface AppletThirdResourcesDao extends BaseDao<AppletThirdResources> {
AppletThirdResources getByResourcesId(Long id);
Integer countResourceIdByGradeLabel(Integer crowdType);
AppletThirdResources getThirdResourceByNumber(String number);
}
......@@ -33,5 +33,13 @@ public class AppletThirdResourcesClickDaoImpl extends BaseDaoImpl<AppletThirdRes
map.put("recordType", recordType);
return getSessionTemplate().selectList(getStatement("mapPVUVByMonth"), map);
}
@Override
public List<PvuvDTO> mapPVUV4BookByResourceId(Long thirdResourceId, Integer recordType) {
Map<String, Object> map = new HashMap<>();
map.put("thirdResourcesId", thirdResourceId);
map.put("recordType", recordType);
return getSessionTemplate().selectList(getStatement("mapPVUV4BookByResourceId"), map);
}
}
......@@ -54,4 +54,9 @@ public class AppletThirdResourcesDaoImpl extends BaseDaoImpl<AppletThirdResource
paramMap.put("crowdType", crowdType);
return getSessionTemplate().selectOne(getStatement("countResourceIdByGradeLabel"), paramMap);
}
@Override
public AppletThirdResources getThirdResourceByNumber(String number) {
return getSessionTemplate().selectOne(getStatement("getThirdResourceByNumber"), number);
}
}
......@@ -15,13 +15,23 @@ import lombok.Data;
public class PvuvDTO extends BaseDto {
private Long fromId;
/**
* 次数
*/
private Integer pv;
/**
* 人数
*/
private Integer uv;
/**
* 数量
*/
private Integer count;
private Long bookId;
private Long channelId;
private Long adviserId;
private Integer recordType;
}
......@@ -19,12 +19,17 @@ import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.readercenter.wechat.exception.WechatUserException;
import com.pcloud.settlementcenter.account.enums.IsSystem;
import java.util.Map;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -179,4 +184,37 @@ public class AppletThirdResourcesFacade {
}
return new ResponseDto<>(thirdResourcesBiz.getThirdResourcesByGradeLabel4ResourcePage(gradeLabelId, currentPage, numPerPage));
}
@ApiOperation("根据编号查第三方资源")
@GetMapping("getThirdResourceByNumber")
public ResponseDto<?> getThirdResourceByNumber(@RequestHeader("token") String token, @RequestParam("number") String number) {
SessionUtil.getInfoToken4Redis(token);
return new ResponseDto<>(thirdResourcesBiz.getThirdResourceByNumber(number));
}
@ApiOperation("第三方资源上书情况")
@GetMapping("listThirdResourceOnBook")
public ResponseDto<?> listThirdResourceOnBook(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "1000") Integer numPerPage,
@RequestParam("thirdResourceId") Long thirdResourceId) {
SessionUtil.getInfoToken4Redis(token);
return new ResponseDto<>(thirdResourcesBiz.listThirdResourceOnBook(currentPage, numPerPage, thirdResourceId));
}
@ApiOperation("导出-第三方资源上书情况")
@GetMapping("exportThirdResourceOnBook")
public ResponseDto<?> exportThirdResourceOnBook(@RequestHeader("token") String token, @RequestParam("thirdResourceId") Long thirdResourceId) {
Map<String,Object> map = SessionUtil.getToken4Redis(token);
String isSystem = (String)map.get(SessionUtil.IS_SYSTEM);
Long pcloudId = (Long) map.get(SessionUtil.PARTY_ID);
if (IsSystem.NOT_SYSTEM.code.equals(isSystem)){
pcloudId = (Long) map.get(SessionUtil.MEMBER_ID);
}
thirdResourcesBiz.exportThirdResourceOnBook(thirdResourceId, pcloudId);
return new ResponseDto<>();
}
}
\ No newline at end of file
......@@ -2,9 +2,12 @@ package com.pcloud.book.consumer.data;
import cn.hutool.core.collection.CollUtil;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.data.domain.dto.BookScanCountParamDTO;
import com.pcloud.data.domain.dto.BookStatisParamDTO;
import com.pcloud.data.domain.dto.QrcodeStatisParamDTO;
import com.pcloud.data.domain.vo.AdsGroupbrowseSummaryVO;
import com.pcloud.data.domain.vo.AllAdviserBookStatisVO;
import com.pcloud.data.domain.vo.AllAdviserWorksStatisVO;
import com.pcloud.data.domain.vo.AllQrcodeWorksStatisVO;
......@@ -233,4 +236,45 @@ public class DataConsr {
}
return null;
}
/**
* 二维码统计(二维码扫码量、浏览量、读者量、平均浏览时长、销售额、购买次数)
*/
public Map<String, CalQrcodeTargetVO> mapQrcodeStatisByBookIds(List<Long> bookIds, List<Long> adviserIds, List<Long> channelIds, List<Long> sceneIds){
if (ListUtils.isEmpty(sceneIds)) {
return new HashMap<>();
}
QrcodeStatisParamDTO paramDTO = new QrcodeStatisParamDTO();
paramDTO.setBookIds(bookIds);
paramDTO.setAdviserIds(adviserIds);
paramDTO.setChannelIds(channelIds);
paramDTO.setQrcodeIds(sceneIds);
try {
ResponseEntity<ResponseDto<Map<String, CalQrcodeTargetVO>>> responseEntity = bookStatisService.mapQrcodeStatisByBookIds(paramDTO);
Map<String, CalQrcodeTargetVO> map = ResponseHandleUtil.parseMap(responseEntity, String.class, CalQrcodeTargetVO.class);
return map != null ? map : new HashMap<>();
} catch (Exception e){
LOGGER.warn("调用数据统计接口 [DataConsr.mapQrcodeStatisByQrcodeId] 失败", e);
}
return new HashMap<>();
}
/**
* @Description 第三方资源数据统计(浏览量浏览人数)
* @Author zhuyajie
* @Date 17:58 2021/12/15
**/
public Map<String, AdsGroupbrowseSummaryVO> mapQrcodeStatisByGroupId(Long groupId) {
if (null == groupId) {
return new HashMap<>();
}
try {
return ResponseHandleUtil.parseMapResponse(bookStatisService.mapQrcodeStatisByGroupId(groupId),String.class,AdsGroupbrowseSummaryVO.class);
} catch (Exception e) {
LOGGER.warn("调用数据统计接口 [DataConsr.mapQrcodeStatisByGroupId] 失败", e);
}
return new HashMap<>();
}
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageUrlDTO;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.ResourcePageItem;
import com.pcloud.book.group.vo.ResourcePageItemVO;
import com.pcloud.common.core.dao.BaseDao;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
import java.util.Map;
......@@ -146,4 +147,11 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{
* * @param null
*/
List<ResourcePageItemVO> getServeListBySceneId4QrUpdate(Long sceneId);
/**
* @Description 资源上书情况
* @Author zhuyajie
* @Date 19:01 2021/12/14
**/
List<ResourceOnBookDTO> listResourceOnBook(Map<String,Object> paramMap);
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.group.dto.ResourcePageUrlDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.BookGroupServe;
......@@ -137,4 +138,9 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple
public List<ResourcePageItemVO> getServeListBySceneId4QrUpdate(Long sceneId) {
return getSessionTemplate().selectList(getStatement("getServeListBySceneId4QrUpdate"), sceneId);
}
@Override
public List<ResourceOnBookDTO> listResourceOnBook(Map<String, Object> paramMap) {
return getSessionTemplate().selectList(getStatement("listResourceOnBook"), paramMap);
}
}
package com.pcloud.book.group.dto;
import com.pcloud.common.dto.BaseDto;
import lombok.Data;
/**
* @ClassName com.pcloud.book.group.dto.ThirdResourceOnBookDTO
* @Author zhuyajie
* @Description 第三方资源上书
* @Date 2021/12/14 17:49
**/
@Data
public class ResourceOnBookDTO extends BaseDto {
private Long serveId;
private String serveType;
private Long sceneId;
private String sceneName;
private Long bookId;
private String bookName;
private String isbn;
private Long adviserId;
private String adviserName;
private String agentName;
private Long channelId;
/**
* 二维码扫码量 浏览量 读者量
**/
private Long scanNum = 0L;
private Long readerNum = 0L;
private Long browseNum = 0L;
/**
* 资源 点击量 点击人数
**/
private Integer resourceClickNum = 0;
private Integer resourceClickUserNum = 0;
}
package com.pcloud.book.skill.biz;
import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.applet.dto.GroupActivity4AppletDTO;
import com.pcloud.book.skill.dto.UpdateActivityShowStateDTO;
......@@ -125,4 +126,25 @@ public interface PcloudGroupActivityBiz {
* * @param null
*/
Map<Long, GroupActivity4AppletDTO> getGroupActivityMap(List<Long> activityGroupIds);
/**
* @Description 根据编号查询
* @Author zhuyajie
* @Date 20:12 2021/12/14
**/
QueryGroupActivityResponseVO getByActivityNumber(String number);
/**
* @Description 第三方群上书情况
* @Author zhuyajie
* @Date 20:18 2021/12/14
**/
PageBeanNew<ResourceOnBookDTO> listGroupActivityOnBook(Integer currentPage, Integer numPerPage, Long groupActivityId);
/**
* @Description 导出-第三方群上书情况
* @Author zhuyajie
* @Date 20:21 2021/12/14
**/
void exportGroupActivityOnBook(Long groupActivityId, Long partyId);
}
package com.pcloud.book.skill.biz.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.alibaba.fastjson.JSONObject;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.applet.dto.AppletGroupStatementDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
......@@ -18,13 +22,20 @@ import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.common.ExportConsr;
import com.pcloud.book.consumer.data.DataConsr;
import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.message.MessageConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.GroupQrcodeBiz;
import com.pcloud.book.group.constant.ResourcePageConstants;
import com.pcloud.book.group.dao.BookClassifyBuyRecordDao;
import com.pcloud.book.group.dao.BookQrcodeUserDao;
import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.group.vo.ClassifyQrcodeVO;
import com.pcloud.book.reading.biz.ReadingActivityBiz;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
......@@ -54,12 +65,16 @@ import com.pcloud.book.skill.facade.request.SaveGroupActivityRequestVO;
import com.pcloud.book.skill.facade.request.UpdateGroupActivityRequestVO;
import com.pcloud.book.skill.facade.response.ListGroupActivityResponseVO;
import com.pcloud.book.skill.facade.response.QueryGroupActivityResponseVO;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.QrcodeUtils;
......@@ -67,15 +82,18 @@ import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.data.domain.vo.AdsGroupbrowseSummaryVO;
import com.pcloud.data.domain.vo.CalQrcodeTargetVO;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.usercenter.party.adviser.service.AdviserService;
import com.pcloud.usercenter.party.agent.service.AgentService;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import com.sdk.wxgroup.RobotProcessTypeEnum;
import com.sdk.wxgroup.SendGroupInviteVO;
import com.sdk.wxgroup.SendPicMessageVO;
import java.util.Arrays;
import java.util.Iterator;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -131,11 +149,10 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
private BookDao bookDao;
@Autowired
private BookClassifyBuyRecordDao bookClassifyBuyRecordDao;
private BookQrcodeUserDao bookQrcodeUserDao;
@Autowired
private AdviserService adviserService;
private AdviserConsr adviserConsr;
@Autowired
private AgentService agentService;
private DataConsr dataConsr;
@Autowired
private RightsNowItemDao rightsNowItemDao;
@Autowired
......@@ -148,6 +165,14 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
private AppletNewsBiz appletNewsBiz;
@Autowired
private AppletLinkClickDao appletLinkClickDao;
@Autowired
private ResourcePageItemDao resourcePageItemDao;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private ExportConsr exportConsr;
@Autowired
private MessageConsr messageConsr;
@ParamLog("批量分类")
@Override
......@@ -847,6 +872,7 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
return localMap;
}
public void setThirdGroupHeadList(List<QueryGroupActivityResponseVO> activityResponseVOList) {
if (ListUtils.isEmpty(activityResponseVOList)) {
return;
......@@ -876,4 +902,136 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
}
}
}
@Override
public QueryGroupActivityResponseVO getByActivityNumber(String number) {
if (StringUtil.isEmpty(number)) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
PcloudGroupActivity pcloudGroupActivity = pcloudGroupActivityDao.getByActivityNumber(number);
QueryGroupActivityResponseVO responseVO = BeanUtil.copyProperties(pcloudGroupActivity,QueryGroupActivityResponseVO.class);
return responseVO;
}
@Override
public PageBeanNew<ResourceOnBookDTO> listGroupActivityOnBook(Integer currentPage, Integer numPerPage, Long groupActivityId) {
if (null == currentPage || null == numPerPage || null == groupActivityId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("serveId", groupActivityId);
paramMap.put("serveType", ResourcePageConstants.ServeTypeEnum.GROUP_ACTIVITY.getValue());
PageBeanNew<ResourceOnBookDTO> pageBeanNew = resourcePageItemDao.listPageNew(new PageParam(currentPage,numPerPage),paramMap,"listResourceOnBook");
if (ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage,numPerPage,pageBeanNew.getTotalCount(),new ArrayList<>());
}
this.fillInfo4OnBook(pageBeanNew.getRecordList(), groupActivityId);
return pageBeanNew;
}
private void fillInfo4OnBook(List<ResourceOnBookDTO> list, Long groupActivityId) {
if (ListUtils.isEmpty(list)) {
return;
}
List<Long> bookIds = new ArrayList<>();
List<Long> channelIds = new ArrayList<>();
List<Long> sceneIds = new ArrayList<>();
List<Long> adviserIds = new ArrayList<>();
for (ResourceOnBookDTO vo:list) {
sceneIds.add(vo.getSceneId());
if (null != vo.getBookId() && !bookIds.contains(vo.getBookId())) {
bookIds.add(vo.getBookId());
}
if (null != vo.getAdviserId() && !adviserIds.contains(vo.getAdviserId())) {
adviserIds.add(vo.getAdviserId());
}
if (null != vo.getChannelId() && !channelIds.contains(vo.getChannelId())) {
channelIds.add(vo.getChannelId());
}
}
//二维码信息
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = qrcodeSceneConsr.listBaseInfoByIds(sceneIds);
//书刊信息
Map<Long, BookDto> bookDtoMap = bookBiz.listBaseByIds(bookIds);
//编辑信息
Map<Long, AdviserBaseInfoDto> adviserDtoMap = adviserConsr.getAdviserId2AdviserInfoDtoMap(adviserIds);
//二维码扫码人数浏览人数
Map<String, CalQrcodeTargetVO> qrcodeStatisMap = dataConsr.mapQrcodeStatisByBookIds(bookIds, adviserIds, channelIds, sceneIds);
//资源点击量点击人数
Map<String, AdsGroupbrowseSummaryVO> groupbrowseSummaryVOMap = dataConsr.mapQrcodeStatisByGroupId(groupActivityId);
for (ResourceOnBookDTO vo:list) {
if (!MapUtils.isEmpty(qrcodeSceneDtoMap) && qrcodeSceneDtoMap.containsKey(vo.getSceneId())) {
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(vo.getSceneId());
vo.setSceneName(qrcodeSceneDto.getSceneName());
}
if (!MapUtils.isEmpty(bookDtoMap) && null != vo.getBookId() && bookDtoMap.containsKey(vo.getBookId())) {
BookDto bookDto = bookDtoMap.get(vo.getBookId());
vo.setBookName(bookDto.getBookName());
vo.setIsbn(bookDto.getIsbn());
}
if (!MapUtils.isEmpty(adviserDtoMap) && null != vo.getAdviserId() && adviserDtoMap.containsKey(vo.getAdviserId())) {
AdviserBaseInfoDto adviserBaseInfoDto = adviserDtoMap.get(vo.getAdviserId());
vo.setAdviserName(adviserBaseInfoDto.getPartyName());
vo.setAgentName(adviserBaseInfoDto.getAgentName());
}
String qrcodeKey = StrUtil.join("-", vo.getBookId(), vo.getAdviserId(), vo.getChannelId(), vo.getSceneId());
if (!MapUtils.isEmpty(qrcodeStatisMap) && qrcodeStatisMap.containsKey(qrcodeKey)) {
CalQrcodeTargetVO statisDTO = qrcodeStatisMap.get(qrcodeKey);
vo.setScanNum(statisDTO.getSca());
vo.setBrowseNum(statisDTO.getPva());
vo.setReaderNum(statisDTO.getUa());
}
if (!MapUtils.isEmpty(groupbrowseSummaryVOMap) && groupbrowseSummaryVOMap.containsKey(qrcodeKey)) {
AdsGroupbrowseSummaryVO groupbrowseSummaryVO = groupbrowseSummaryVOMap.get(qrcodeKey);
vo.setResourceClickNum(groupbrowseSummaryVO.getBrowseCnt().intValue());
vo.setResourceClickUserNum(groupbrowseSummaryVO.getBrowseUsers().intValue());
}
}
}
@Override
public void exportGroupActivityOnBook(Long groupActivityId, Long partyId) {
if (null == groupActivityId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
ThreadPoolUtils.EXPORT_THREAD_POOL.execute(()->{
PcloudGroupActivity groupActivity = pcloudGroupActivityDao.getById(groupActivityId);
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("serveId", groupActivityId);
paramMap.put("serveType", ResourcePageConstants.ServeTypeEnum.GROUP_ACTIVITY.getValue());
List<ResourceOnBookDTO> list = resourcePageItemDao.listResourceOnBook(paramMap);
if (ListUtils.isEmpty(list)) {
return;
}
this.fillInfo4OnBook(list, groupActivityId);
List<Object[]> excelDatas = new ArrayList<>();
String[] rowsName = {"二维码ID","二维码名称", "书刊ID", "书刊名称", "isbn", "编辑名称", "出版社名称", "二维码扫码量", "二维码读者量","二维码浏览量","点击量","点击人数"};
for (ResourceOnBookDTO vo : list) {
Object[] objs = new Object[rowsName.length];
objs[0] = vo.getSceneId();
objs[1] = vo.getSceneName();
objs[2] = vo.getBookId();
objs[3] = vo.getBookName();
objs[4] = vo.getIsbn();
objs[5] = vo.getAdviserName();
objs[6] = vo.getAgentName();
objs[7] = vo.getScanNum();
objs[8] = vo.getReaderNum();
objs[9] = vo.getBrowseNum();
objs[10] = vo.getResourceClickNum();
objs[11] = vo.getResourceClickUserNum();
excelDatas.add(objs);
}
String title = groupActivity.getName()+"-第三方社群上书明细";
String fileUrl = exportConsr.exportExcel(title, rowsName, excelDatas);
if (!StringUtil.isEmpty(fileUrl)) {
String letterType = "qrcode_download";
String fileName = title + DateUtils.today();
JSONObject content = new JSONObject();
content.put("commitTime", DateUtils.formatDate(new Date()));
content.put("type",title);
messageConsr.sendLetter(0L, partyId, content.toJSONString(), SystemCode.pcloud.code, letterType, fileUrl, fileName);
}
});
}
}
......@@ -42,4 +42,6 @@ public interface PcloudGroupActivityDao extends BaseDao<PcloudGroupActivity> {
QueryGroupActivityResponseVO getByActivityId(Long id);
Map<Long, GroupActivity4AppletDTO> getGroupClassifyByIds4Record(List<Long> bookGroupIds);
PcloudGroupActivity getByActivityNumber(String number);
}
......@@ -123,5 +123,10 @@ public class PcloudGroupActivityDaoImpl extends BaseDaoImpl<PcloudGroupActivity>
return super.getSqlSession().selectMap(getStatement("getGroupClassifyByIds4Record"), bookGroupIds,"id");
}
@Override
public PcloudGroupActivity getByActivityNumber(String number) {
return getSessionTemplate().selectOne(getStatement("getByActivityNumber"), number);
}
}
package com.pcloud.book.skill.facade;
import com.pcloud.book.group.dto.ResourceOnBookDTO;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dto.UpdateActivityShowStateDTO;
import com.pcloud.book.skill.facade.request.GroupActivityClassifyVO;
......@@ -12,6 +13,8 @@ import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.settlementcenter.account.enums.IsSystem;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -146,4 +149,34 @@ public class PcloudGroupActivityFacade {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(pcloudGroupActivityBiz.getByActivityId(id));
}
@ApiOperation("根据编号查询")
@GetMapping("getByActivityNumber")
public ResponseDto<?> getByActivityNumber(@RequestHeader("token") String token, @RequestParam("number") String number){
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(pcloudGroupActivityBiz.getByActivityNumber(number));
}
@ApiOperation("第三方群上书情况")
@GetMapping("listGroupActivityOnBook")
public ResponseDto<?> listGroupActivityOnBook(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "1000") Integer numPerPage,
@RequestParam("groupActivityId") Long groupActivityId) {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(pcloudGroupActivityBiz.listGroupActivityOnBook(currentPage, numPerPage, groupActivityId));
}
@ApiOperation("导出-第三方群上书情况")
@GetMapping("exportGroupActivityOnBook")
public ResponseDto<?> exportGroupActivityOnBook(@RequestHeader("token") String token, @RequestParam("groupActivityId") Long groupActivityId) {
Map<String,Object> map = SessionUtil.getToken4Redis(token);
String isSystem = (String)map.get(SessionUtil.IS_SYSTEM);
Long pcloudId = (Long) map.get(SessionUtil.PARTY_ID);
if (IsSystem.NOT_SYSTEM.code.equals(isSystem)){
pcloudId = (Long) map.get(SessionUtil.MEMBER_ID);
}
pcloudGroupActivityBiz.exportGroupActivityOnBook(groupActivityId, pcloudId);
return new ResponseDto<>();
}
}
......@@ -341,4 +341,11 @@
</select>
<select id="getThirdResourceByNumber" parameterType="string" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from applet_third_resources
where resource_number = #{number}
limit 1
</select>
</mapper>
\ No newline at end of file
......@@ -139,7 +139,26 @@
</if>
</where>
order by a.create_time desc
</select>
<select id="mapPVUV4BookByResourceId" parameterType="map" resultType="com.pcloud.book.applet.dto.PvuvDTO">
SELECT
third_resources_id fromId,
COUNT(1) pv,
COUNT(DISTINCT wechat_user_id) uv,
book_id bookId,
channel_id channelId,
adviser_id adviserId,
record_type recordType
FROM
applet_thirdresources_click_record
WHERE
third_resources_id = #{thirdResourcesId}
<if test="recordType != null">
and record_type = #{recordType}
</if>
GROUP BY
book_id,adviser_id,channel_id,record_type
</select>
</mapper>
......@@ -402,4 +402,25 @@
n.navigation_seq ASC, c.column_seq ASC, i.id ASC
</select>
<select id="listResourceOnBook" parameterType="map" resultType="com.pcloud.book.group.dto.ResourceOnBookDTO">
SELECT
i.serve_id serveId,
i.serve_type serveType,
p.scene_id sceneId,
p.book_id bookId,
p.create_user adviserId,
p.channel_id channelId
FROM
resource_page_item i
LEFT JOIN resource_page p ON i.resource_page_id = p.id
WHERE
i.serve_id = #{serveId}
AND i.serve_type = #{serveType}
AND p.scene_id > 0
GROUP BY
p.scene_id
ORDER BY i.create_time DESC
</select>
</mapper>
\ No newline at end of file
......@@ -771,4 +771,12 @@
GROUP BY c.id
ORDER BY c.id DESC
</select>
<select id="getByActivityNumber" parameterType="string" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from pcloud_group_activity
where number = #{number}
limit 1
</select>
</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