Commit 88398595 by 吴博

feat: [1004620] 资讯处理

parent c71d04ae
package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
@Data
public class ArticleInfoDTO implements Serializable {
//类型
private String type;
//排序值
private Integer seqNum;
//内容
private String content;
//音乐名称
private String musicName;
//音乐地址
private String musicUrl;
}
package com.pcloud.book.applet.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class HandleNewsDTO {
private Long bookId;
private Long adviserId;
private Long channelId;
private Long adviserBookId;
private List<Long> appletNewsIds;
}
......@@ -14,6 +14,7 @@ import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductLabelDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import com.pcloud.resourcecenter.product.dto.UpdateAppProductParamDTO;
import com.pcloud.resourcecenter.product.entity.Article;
import com.pcloud.resourcecenter.product.entity.Product;
import com.pcloud.resourcecenter.product.service.ProductService;
......@@ -347,4 +348,29 @@ public class ProductConsr {
return productDtoMap == null ? new HashMap<>() : productDtoMap;
}
public Long addProductStepOne(Product product) {
Long productId = null;
try {
productId = ResponseHandleUtil.parseResponse(productService.addProductStepOne(product), Long.class);
} catch (Exception e) {
LOGGER.error("创建作品第一步[productService.addProductStepOne]:创建失败:product:{}" + e.getMessage(), product);
}
return productId;
}
public void addArticle(Article article) {
try {
productService.addArticle(article);
} catch (Exception e) {
LOGGER.error("创建精品文章第二步[productService.addArticle]:创建失败:article:{}" + e.getMessage(), article);
}
}
public void selfAudit(Product product) {
try {
productService.selfAudit(product);
} catch (Exception e) {
LOGGER.error("自主审核失败[productService.selfAudit]:创建失败:article:{}" + e.getMessage(), product);
}
}
}
......@@ -143,4 +143,12 @@ public interface ResourcePageBiz {
* * @param null
*/
void batchUpdateQrcode(List<Long> bookGroupIds);
/**
* 根据书籍id和channel获取资源配置页
* @param adviserBookId
* @param channelId
* @return
*/
ResourcePageVO getResourcePageByBookIdAndChannelId(Long adviserBookId, Long channelId);
}
......@@ -1261,4 +1261,14 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
}
@Override
public ResourcePageVO getResourcePageByBookIdAndChannelId(Long bookId, Long channelId) {
ResourcePageVO resourcePageVO = new ResourcePageVO();
ResourcePage resourcePage = resourcePageDao.getByBookId(bookId, channelId, null);
if (null != resourcePage) {
BeanUtils.copyProperties(resourcePage, resourcePageVO);
}
return resourcePageVO;
}
}
......@@ -268,4 +268,9 @@ public interface RightsSettingBiz {
* 根据图书信息及权益ID检查是否配置了读书卡片应用
*/
Map<String,Object> getBookCardId4Book(Long bookId, Long channelId, Long adviserId, Long rightsSettingId);
/**
* 处理资讯
*/
void handleNews();
}
......@@ -20,14 +20,13 @@ import com.pcloud.book.applet.biz.ServeCollectBiz;
import com.pcloud.book.applet.dao.AppletNewsDao;
import com.pcloud.book.applet.dao.AppletThirdResourcesDao;
import com.pcloud.book.applet.dao.AppletUserBookcaseDao;
import com.pcloud.book.applet.dto.AppletBannerDTO;
import com.pcloud.book.applet.dto.AppletGroupStatementDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.AppletOuterBooklistDTO;
import com.pcloud.book.applet.dto.ServeItemInfoDTO;
import com.pcloud.book.applet.dto.ArticleInfoDTO;
import com.pcloud.book.applet.dto.HandleNewsDTO;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesPic;
import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.book.applet.enums.AppletRecordTypeEnum;
......@@ -57,6 +56,7 @@ import com.pcloud.book.custom.mapper.CustomPlanMapper;
import com.pcloud.book.giftcoupon.dao.GiftReceiveDao;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.GroupQrcodeBiz;
import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookServeDTO;
......@@ -65,6 +65,10 @@ import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.enums.QrcodeJumpType;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.group.vo.ClassifyQrcodeVO;
import com.pcloud.book.group.vo.ResourceColumnAndServeVO;
import com.pcloud.book.group.vo.ResourcePageItemVO;
import com.pcloud.book.group.vo.ResourcePageVO;
import com.pcloud.book.group.vo.UpdateResourceColumnVO;
import com.pcloud.book.push.dao.PersonalAppletsDao;
import com.pcloud.book.rightsSetting.biz.RightsSettingBannerBiz;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
......@@ -134,10 +138,16 @@ import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.ServeLinkUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.json.JSONUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.labelcenter.label.service.LabelService;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.entity.Article;
import com.pcloud.resourcecenter.product.entity.Product;
import com.pcloud.resourcecenter.product.entity.ProductLabel;
import com.pcloud.resourcecenter.product.entity.Specification;
import com.pcloud.usercenter.common.enums.SystemRoleCodeEnum;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.CollectionUtils;
......@@ -274,6 +284,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private AppletThirdResourcesBiz appletThirdResourcesBiz;
@Autowired
private AppletThirdResourcesPicMapper appletThirdResourcesPicMapper;
@Autowired
private ResourcePageBiz resourcePageBiz;
@Override
@ParamLog("新增权益设置")
......@@ -1165,6 +1177,158 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
return new HashMap<>();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void handleNews() {
List<AppletNews> appletNews = rightsSettingDAO.getAllNews();
if (ListUtils.isEmpty(appletNews)) {
return;
}
Map<Long ,AppletNews> appletNewsMap = appletNews.stream().collect(Collectors.toMap(AppletNews::getId,Function.identity(), (key1, key2) -> key2));
//获取资讯与作品关系集合
Map<Long, Long> newsProductMap = getNewsProductMap(appletNews);
if (MapUtils.isEmpty(newsProductMap)) {
return;
}
//获取所有书刊与资讯的关系
List<HandleNewsDTO> handleNewsDtos = rightsSettingDAO.getAllBookNews();
if (ListUtils.isEmpty(handleNewsDtos)) {
return;
}
handleNewsDtos.stream().forEach(bookNews -> {
//根据bookid 和channel 查询book_groupId 以及对应的编辑端资源 判断是否有应用作品模块 并新增资源
ResourcePageVO resourcePageVO = resourcePageBiz.getResourcePageByBookIdAndChannelId(bookNews.getBookId(), bookNews.getChannelId());
if (null == resourcePageVO || null == resourcePageVO.getId()) {
return;
}
List<ResourceColumnAndServeVO> serveVOList = resourcePageBiz.getColumnAndServeListByPageId(resourcePageVO.getId(), false);
UpdateResourceColumnVO columnVO = new UpdateResourceColumnVO();
columnVO.setColumnFormat(3);
columnVO.setColumnName("精品资讯");
Integer serveCount = ListUtils.isEmpty(serveVOList) ? 0 : serveVOList.size();
columnVO.setColumnSeq(++serveCount);
columnVO.setColumnType(1);
columnVO.setResourcePageId(resourcePageVO.getId());
columnVO.setShowCount(4);
//新增内容
if (ListUtils.isEmpty(bookNews.getAppletNewsIds())) {
return;
}
BookAdviserDto bookAdviserDto = null;
if (null != bookNews.getBookId() && (null == bookNews.getChannelId() || null == bookNews.getAdviserId())) {
bookAdviserDto = bookAdviserBiz.getOneMainBook(bookNews.getBookId());
} else if (null != bookNews.getBookId() && null != bookNews.getChannelId() && null != bookNews.getAdviserId()) {
bookAdviserDto = bookAdviserBiz.getBase(bookNews.getBookId(), bookNews.getChannelId(),bookNews.getAdviserId());
}
if (null == bookAdviserDto) {
return;
}
List<ResourcePageItemVO> itemVOList = new ArrayList<>();
BookAdviserDto finalBookAdviserDto = bookAdviserDto;
bookNews.getAppletNewsIds().stream().forEach(newsId -> {
ResourcePageItemVO resourcePageItemVO = new ResourcePageItemVO();
resourcePageItemVO.setServeType("PRODUCT");
String pic;
if (MapUtils.isEmpty(newsProductMap) || null == newsProductMap.get(newsId)) {
return;
}
if (MapUtils.isEmpty(appletNewsMap) || null == appletNewsMap.get(newsId)) {
return;
}
if (!StringUtil.isEmpty(appletNewsMap.get(newsId).getPic1())){
pic = appletNewsMap.get(newsId).getPic1();
} else {
pic = "https://oss.5rs.me/oss/uploadfe/jpg/5b47ff1c2b9a47a7d9fab10ef0990255.jpg";
}
resourcePageItemVO.setServePic(pic);
if (!StringUtil.isEmpty(appletNewsMap.get(newsId).getNewsName())) {
resourcePageItemVO.setServeName(appletNewsMap.get(newsId).getNewsName());
}
resourcePageItemVO.setServeId(newsProductMap.get(newsId));
String linkUrl = "/C"+ finalBookAdviserDto.getChannelId()+"/product/display/"+ resourcePageItemVO.getServeId()+
"?adviserId="+ finalBookAdviserDto.getAdviserId()+"&proType=ARTICLE&source_type=QRCODE";
resourcePageItemVO.setLinkUrl(linkUrl);
itemVOList.add(resourcePageItemVO);
});
if (ListUtils.isEmpty(itemVOList)) {
return;
}
columnVO.setItemVOList(itemVOList);
log.info("columnVO:{}", columnVO);
resourcePageBiz.updateResourceColumn(columnVO);
return;
});
List<Long> allNewsIds = appletNews.stream().map(e -> e.getId()).collect(Collectors.toList());
allNewsIds.removeAll(newsProductMap.keySet());
log.info("没有转成作品的资讯id是:{}", allNewsIds);
}
private Map<Long, Long> getNewsProductMap(List<AppletNews> appletNews) {
String defaultPic1 = "https://oss.5rs.me/oss/uploadfe/jpg/5b47ff1c2b9a47a7d9fab10ef0990255.jpg";
Long partyId = null;
if (envStr.equalsIgnoreCase("test")) {
partyId = 1404L;
} else if (envStr.equalsIgnoreCase("uat")) {
partyId = 12829L;
} else if (envStr.equalsIgnoreCase("pro")) {
partyId = 1000022269L;
}
String title = "共享教育";
Map<Long, Long> newsProductMap = new HashMap<>();
//填充数据
Long finalPartyId = partyId;
appletNews.stream().forEach(news -> {
Product product = new Product();
product.setCoverImg("https://oss.5rs.me/oss/uploadfe/jpg/03024429744ee9bf16abc728236b7ee7.jpg");
product.setDetailDesc(StringUtil.isEmpty(news.getDigest()) ? news.getNewsName() : news.getDigest());
product.setPicture1(StringUtil.isEmpty(news.getPic1()) ? defaultPic1 : news.getPic1());
ProductLabel productLabel = new ProductLabel();
productLabel.setProLabelId(null == news.getProLabelId() ? 469L : news.getProLabelId());
productLabel.setDepLabelId(null == news.getDepLabelId() ? 470L : news.getDepLabelId());
productLabel.setPurLabelId(null == news.getPurLabelId() ? 245L : news.getPurLabelId());
product.setProLabelGroup(Lists.newArrayList(productLabel));
product.setProductName(news.getNewsName());
product.setProductTypeId(28L);
Specification specification = new Specification();
specification.setAdvisePrice(0.00);
specification.setDealPrice(0.00);
product.setSpecification(Lists.newArrayList(specification));
product.setUniqueNumber(news.getUrlNumber());
//共享教育作者id
product.setCreatedUser(finalPartyId);
product.setCreatedUserRole(SystemRoleCodeEnum.MERCHANT.name().toLowerCase());
Long productId = productConsr.addProductStepOne(product);
if (null == productId) {
return;
}
product.setProductId(productId);
Article article = new Article();
article.setProductId(productId);
article.setPreReading(20L);
article.setTitle(StringUtil.isEmpty(news.getSource()) ? title : news.getSource());
article.setCreatedUser(finalPartyId);
List<ArticleInfoDTO> articleInfoDTOS = new ArrayList<>();
ArticleInfoDTO articleInfo4Content = new ArticleInfoDTO();
articleInfo4Content.setType("text");
articleInfo4Content.setSeqNum(0);
articleInfo4Content.setContent(news.getContent());
articleInfoDTOS.add(articleInfo4Content);
ArticleInfoDTO articleInfo4Music = new ArticleInfoDTO();
articleInfo4Music.setType("bgmusic");
articleInfo4Music.setSeqNum(1);
articleInfoDTOS.add(articleInfo4Music);
article.setInfo(JSONUtils.toJsonString(articleInfoDTOS));
productConsr.addArticle(article);
productConsr.selfAudit(product);
if (null != news.getId() && null != productId) {
newsProductMap.put(news.getId(), productId);
}
});
return newsProductMap;
}
private void fillRightsNowItems4New(RightsSetting rightsSetting) {
log.info("即享权益填充详情");
List<Integer> types = new ArrayList<>();
......
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.applet.dto.HandleNewsDTO;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.rightsSetting.dto.BookRightsCountsDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO;
......@@ -40,4 +42,8 @@ public interface RightsSettingDAO extends BaseDao<RightsSetting> {
void updateUser(RightsSetting rightsSetting);
RightsSettingDto getDTOById(Long id);
List<AppletNews> getAllNews();
List<HandleNewsDTO> getAllBookNews();
}
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.applet.dto.HandleNewsDTO;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dto.BookRightsCountsDto;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
......@@ -100,6 +102,16 @@ public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implement
}
@Override
public List<AppletNews> getAllNews() {
return getSessionTemplate().selectList(getStatement("getAllNews"));
}
@Override
public List<HandleNewsDTO> getAllBookNews() {
return getSessionTemplate().selectList(getStatement("getAllBookNews"));
}
@Override
public List<BookRightsCountsDto> rightsCountByBookIds(List<Long> bookIds) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookIds",bookIds);
......
......@@ -429,4 +429,11 @@ public class RightsSettingFacede {
@RequestParam(value = "rightsSettingId",required = false) Long rightsSettingId) {
return new ResponseDto<>(rightsSettingBiz.getBookCardId4Book(bookId, channelId, adviserId, rightsSettingId));
}
@ApiOperation("将资讯转成作品")
@GetMapping("handleNews")
public ResponseDto<?> handleNews() {
rightsSettingBiz.handleNews();
return new ResponseDto<>();
}
}
\ No newline at end of file
......@@ -77,12 +77,16 @@
p.open_rays
FROM
resource_page p
INNER JOIN book_group g ON p.book_group_id = g.id
INNER JOIN book_group g ON p.book_group_id = g.id and g.is_delete = 0
AND g.join_group_type = 4
WHERE
g.book_id = #{bookId}
AND g.channel_id = #{channelId}
AND g.create_user = #{adviserId}
<if test="channelId != null">
AND g.channel_id = #{channelId}
</if>
<if test="adviserId != null">
AND g.create_user = #{adviserId}
</if>
ORDER BY
p.open_rays DESC, p.book_group_id desc
LIMIT 1
......
......@@ -76,6 +76,16 @@
column="id" select="com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper.selectBookByRithsSettingId">
</collection>
</resultMap>
<resultMap id="BookNewsDTOMap" type="com.pcloud.book.applet.dto.HandleNewsDTO">
<result column="book_adviser_id" property="adviserBookId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<collection property="appletNewsIds" ofType="long">
<result column="serve_id" jdbcType="BIGINT"/>
</collection>
</resultMap>
<sql id="Base_Column_List" >
id,rights_number, introduce, detail, count, first_classify, second_classify, third_classify,grade_label_id, subject_label_id,
create_time, update_time, enable_group_service, rights_setting_type, book_id
......@@ -459,4 +469,46 @@ WHERE
GROUP BY a.book_id
</select>
<select id="getAllNews" resultMap="com.pcloud.book.applet.dao.impl.AppletNewsDaoImpl.BaseResultMap">
select
news.id, news.news_name, news.source, news.news_classify_id, news.pro_label_id, news.dep_label_id, news.pur_label_id, news.type, news.digest,
pic1, pic2, pic3, news.content, news.create_time, news.update_time, news.first_classify, news.second_classify, news.grade_label_id, news.subject_label_id, news.rights_classify_id,
news.jump_type, news.jump_url, news.url_number, news.custom_tag_id
from
rights_setting a
inner join
rights_setting_book_relation c on a.id = c.rights_setting_id
inner join
rights_now_item b on a.id = b.rights_setting_id
inner join
applet_news news on b.serve_id = news.id
where
a.rights_setting_type = 2
and
b.serve_type = 'NEWS'
and
content is not null
group by news.id
</select>
<select id="getAllBookNews" resultMap="BookNewsDTOMap">
SELECT
c.book_adviser_id,
c.book_id,
c.adviser_id,
c.channel_id,
b.serve_id
FROM
rights_setting a
INNER JOIN rights_setting_book_relation c ON a.id = c.rights_setting_id
INNER JOIN rights_now_item b ON a.id = b.rights_setting_id
INNER JOIN applet_news news ON b.serve_id = news.id
INNER JOIN book_group d ON c.book_id = d.book_id
INNER JOIN resource_page e ON e.book_group_id = d.id
WHERE
a.rights_setting_type = 2
AND b.serve_type = 'NEWS'
AND content IS NOT NULL
</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