Commit 266f5a95 by 阮思源

1002476阶段非关键词回复支持音视频文件回复方式

parent cb3064c9
package com.pcloud.book.personalstage.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.mq.delay.DelayMessageSender;
......@@ -35,7 +36,9 @@ import com.pcloud.common.utils.ListUtils;
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.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.wechatgroup.group.dto.GroupUserDTO;
import com.sdk.wxgroup.SendFileVO;
import com.sdk.wxgroup.SendMessageTypeEnum;
import com.sdk.wxgroup.SendPicMessageVO;
import com.sdk.wxgroup.SendTextMessageVO;
......@@ -96,6 +99,8 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
private PersonalStageProgressMessageDao personalStageProgressMessageDao;
@Autowired
private PersonalStageJumpLinkupDao personalStageJumpLinkupDao;
@Autowired
private ResourceConsr resourceConsr;
@Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix;
......@@ -165,6 +170,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
List<Long> replyIds=replies.stream().map(PersonalStageReply::getId).collect(Collectors.toList());
List<PersonalStageReplyItem> replyItems = personalStageReplyItemDao.getListByReplyIds(replyIds);
if (!ListUtils.isEmpty(replyItems)){
fillReplyItems(replyItems);
Map<Long,List<PersonalStageReplyItem>> itemMap=replyItems.stream().collect(Collectors.groupingBy(PersonalStageReplyItem::getPersonalStageReplyId));
for (PersonalStageReply reply:replies){
reply.setPersonalStageReplyItems(itemMap.get(reply.getId()));
......@@ -183,6 +189,34 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
return personalStage;
}
@ParamLog("填充回复项")
private void fillReplyItems(List<PersonalStageReplyItem> replyItems) {
if (ListUtils.isEmpty(replyItems)){
return;
}
List<Long> resourceIds=replyItems.stream().filter(s->ReplyTypeEnum.RESOURCE.value.equals(s.getReplyType())&&s.getResourceId()!=null).map(PersonalStageReplyItem::getResourceId).collect(Collectors.toList());
if (ListUtils.isEmpty(resourceIds)){
return;
}
Map<Long, ResourceDTO> resourceDTOMap = resourceConsr.mapByIds(resourceIds);
for (PersonalStageReplyItem item:replyItems){
Integer type=item.getReplyType();
if (ReplyTypeEnum.RESOURCE.value.equals(type)){
ResourceDTO resourceDTO = resourceDTOMap.get(item.getResourceId());
if (resourceDTO!=null){
item.setResourceName(resourceDTO.getResourceName());
item.setResourceUrl(resourceDTO.getFileUrl());
item.setResourceTypeCode(resourceDTO.getTypeCode());
item.setResourceTypeName(resourceDTO.getTypeName());
item.setFileType(resourceDTO.getFileType());
item.setResourcePdfItems(resourceDTO.getResourcePdfItems());
item.setResourceOfficeItemDTOs(resourceDTO.getResourceOfficeItemDTOs());
item.setFileSize(resourceDTO.getFileSize());
}
}
}
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("修改排序值")
@Override
......@@ -713,6 +747,26 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
sendPicMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
WxGroupSDK.sendPicMessage(sendPicMessageVO);
}
if (ReplyTypeEnum.RESOURCE.value.equals(type)) {
SendFileVO sendFileVO = new SendFileVO();
Map<Long, ResourceDTO> map = resourceConsr.mapByIds(Arrays.asList(item.getResourceId()));
ResourceDTO resourceDTO = map.get(item.getResourceId());
if (resourceDTO != null) {
sendFileVO.setFileUrl(resourceDTO.getFileUrl());
String fileName = resourceDTO.getResourceName();
String fileType = resourceDTO.getFileType();
LOGGER.info("fileName="+fileName+"+fileType+"+fileType);
if (fileName.contains(fileType)){//去掉后缀
fileName = fileName.substring(0, fileName.indexOf(fileType)-1);
}
LOGGER.info("fileName="+fileName);
sendFileVO.setFileName(fileName);
}
sendFileVO.setIp(ip);
sendFileVO.setAltId(robotId);
sendFileVO.setWxId(userWxId);
WxGroupSDK.sendFile(sendFileVO);
}
}
}
......
......@@ -103,6 +103,9 @@ public class PersonalStageCheck {
if (ReplyTypeEnum.IMAGE.value.equals(item.getReplyType())&&StringUtil.isEmpty(item.getPicUrl())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项图片不能为空!");
}
if (ReplyTypeEnum.RESOURCE.value.equals(item.getReplyType())&&item.getResourceId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"资源id不能为空!");
}
}
}
......
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import com.pcloud.contentcenter.resource.dto.ResourceOfficeItemDTO;
import com.pcloud.contentcenter.resource.dto.ResourcePdfItemDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("定制化阶段回复项")
@Data
public class PersonalStageReplyItem extends BaseEntity {
......@@ -21,4 +25,31 @@ public class PersonalStageReplyItem extends BaseEntity {
@ApiModelProperty("图片地址")
private String picUrl;
@ApiModelProperty("资源id")
private Long resourceId;
@ApiModelProperty("资源链接")
private String resourceUrl;
@ApiModelProperty("资源名称")
private String resourceName;
@ApiModelProperty("资源类型编码")
private String resourceTypeCode;
@ApiModelProperty("资源类型名称")
private String resourceTypeName;
@ApiModelProperty("文件类型")
private String fileType;
@ApiModelProperty("pdf转码后的单张图片集合")
private List<ResourcePdfItemDTO> resourcePdfItems;
@ApiModelProperty("文件转码后的单张图片集合")
private List<ResourceOfficeItemDTO> resourceOfficeItemDTOs;
@ApiModelProperty("文件大小")
private Long fileSize;
}
\ No newline at end of file
......@@ -8,11 +8,12 @@
<result property="replyType" column="reply_type" jdbcType="INTEGER"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="resourceId" column="resource_id" jdbcType="BIGINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_reply_id, reply_type, content, pic_url, create_time
id, personal_stage_reply_id, reply_type, content, pic_url, resource_id, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -34,6 +35,7 @@
reply_type,
content,
pic_url,
resource_id,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
......@@ -41,6 +43,7 @@
#{replyType,jdbcType=INTEGER},
#{content,jdbcType=VARCHAR},
#{picUrl,jdbcType=VARCHAR},
#{resourceId,jdbcType=BIGINT},
NOW()
</trim>
</insert>
......@@ -51,6 +54,7 @@
reply_type,
content,
pic_url,
resource_id,
create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
......@@ -59,6 +63,7 @@
#{item.replyType,jdbcType=INTEGER},
#{item.content,jdbcType=VARCHAR},
#{item.picUrl,jdbcType=VARCHAR},
#{item.resourceId,jdbcType=BIGINT},
NOW()
)
</foreach>
......
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