Commit da48cf4b by 1244575290@qq.com

欢迎语间隔时间

parent 2f5d58dc
...@@ -27,6 +27,7 @@ import com.pcloud.book.pcloudkeyword.entity.PcloudTd; ...@@ -27,6 +27,7 @@ import com.pcloud.book.pcloudkeyword.entity.PcloudTd;
import com.pcloud.book.pcloudkeyword.entity.PcloudTdRecord; import com.pcloud.book.pcloudkeyword.entity.PcloudTdRecord;
import com.pcloud.book.pcloudkeyword.enums.WelcomeReplyTypeEnum; import com.pcloud.book.pcloudkeyword.enums.WelcomeReplyTypeEnum;
import com.pcloud.book.push.biz.SelfPushBiz; import com.pcloud.book.push.biz.SelfPushBiz;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
...@@ -42,6 +43,8 @@ import com.sdk.wxgroup.SendMessageTypeEnum; ...@@ -42,6 +43,8 @@ import com.sdk.wxgroup.SendMessageTypeEnum;
import com.sdk.wxgroup.SendPicMessageVO; import com.sdk.wxgroup.SendPicMessageVO;
import com.sdk.wxgroup.SendTextMessageVO; import com.sdk.wxgroup.SendTextMessageVO;
import com.sdk.wxgroup.WxGroupSDK; import com.sdk.wxgroup.WxGroupSDK;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -57,6 +60,9 @@ import java.util.stream.Collectors; ...@@ -57,6 +60,9 @@ import java.util.stream.Collectors;
@Component("pcloudRobotBiz") @Component("pcloudRobotBiz")
public class PcloudRobotBizImpl implements PcloudRobotBiz { public class PcloudRobotBizImpl implements PcloudRobotBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(PcloudRobotBizImpl.class);
@Autowired @Autowired
private PcloudRobotDao pcloudRobotDao; private PcloudRobotDao pcloudRobotDao;
@Autowired @Autowired
...@@ -182,53 +188,61 @@ public class PcloudRobotBizImpl implements PcloudRobotBiz { ...@@ -182,53 +188,61 @@ public class PcloudRobotBizImpl implements PcloudRobotBiz {
@Override @Override
public void sendWelcomeReply(String robotWxId, String userWxId, String ip) { public void sendWelcomeReply(String robotWxId, String userWxId, String ip) {
Map<String, Object> map = new HashMap<>(); ThreadPoolUtils.OTHER_THREAD_POOL.execute(() -> {
map.put("robotWxId", robotWxId); Map<String, Object> map = new HashMap<>();
PcloudRobot pcloudRobot = (PcloudRobot)pcloudRobotDao.getBy(map, "getByRobotWxId"); map.put("robotWxId", robotWxId);
if(pcloudRobot != null) { PcloudRobot pcloudRobot = (PcloudRobot)pcloudRobotDao.getBy(map, "getByRobotWxId");
List<PcloudRobotWelcome> robotWelcomeList = pcloudRobotWelcomeDao.getRobotWelcomeListByPcloudRobotId(pcloudRobot.getId()); if(pcloudRobot != null) {
fillRobotWelcome(robotWelcomeList); Integer welcomeDuration = pcloudRobot.getWelcomeDuration() == null ? 3 : pcloudRobot.getWelcomeDuration();
for (PcloudRobotWelcome robotWelcome : robotWelcomeList) { List<PcloudRobotWelcome> robotWelcomeList = pcloudRobotWelcomeDao.getRobotWelcomeListByPcloudRobotId(pcloudRobot.getId());
Integer replyType = robotWelcome.getReplyType(); fillRobotWelcome(robotWelcomeList);
if(WelcomeReplyTypeEnum.TEXT.value.equals(replyType)) { for (PcloudRobotWelcome robotWelcome : robotWelcomeList) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO(); try {
sendTextMessageVO.setContent(robotWelcome.getContent()); Thread.sleep(1000 * welcomeDuration);
sendTextMessageVO.setAltId(robotWxId); } catch (InterruptedException e) {
sendTextMessageVO.setWxGroupId(userWxId); LOGGER.error("线程睡眠出错==", e);
sendTextMessageVO.setIp(ip); }
sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode()); Integer replyType = robotWelcome.getReplyType();
WxGroupSDK.sendTextMessage(sendTextMessageVO); if(WelcomeReplyTypeEnum.TEXT.value.equals(replyType)) {
} else if(WelcomeReplyTypeEnum.IMAGE.value.equals(replyType)) { SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
SendPicMessageVO sendPicMessageVO = new SendPicMessageVO(); sendTextMessageVO.setContent(robotWelcome.getContent());
sendPicMessageVO.setWxGroupId(userWxId); sendTextMessageVO.setAltId(robotWxId);
sendPicMessageVO.setAltId(robotWxId); sendTextMessageVO.setWxGroupId(userWxId);
sendPicMessageVO.setPicUrl(robotWelcome.getPicUrl()); sendTextMessageVO.setIp(ip);
sendPicMessageVO.setIp(ip); sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendPicMessageVO.setCode(SendMessageTypeEnum.SELF.getCode()); WxGroupSDK.sendTextMessage(sendTextMessageVO);
WxGroupSDK.sendPicMessage(sendPicMessageVO); } else if(WelcomeReplyTypeEnum.IMAGE.value.equals(replyType)) {
} else if(WelcomeReplyTypeEnum.RESOURCE.value.equals(replyType)) { SendPicMessageVO sendPicMessageVO = new SendPicMessageVO();
SendFileVO sendFileVO = new SendFileVO(); sendPicMessageVO.setWxGroupId(userWxId);
sendFileVO.setFileUrl(robotWelcome.getResourceUrl()); sendPicMessageVO.setAltId(robotWxId);
sendFileVO.setFileName(robotWelcome.getResourceName()); sendPicMessageVO.setPicUrl(robotWelcome.getPicUrl());
sendFileVO.setIp(ip); sendPicMessageVO.setIp(ip);
sendFileVO.setAltId(robotWxId); sendPicMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendFileVO.setWxId(userWxId); WxGroupSDK.sendPicMessage(sendPicMessageVO);
sendFileVO.setCode(SendMessageTypeEnum.SELF.getCode()); } else if(WelcomeReplyTypeEnum.RESOURCE.value.equals(replyType)) {
WxGroupSDK.sendFile(sendFileVO); SendFileVO sendFileVO = new SendFileVO();
sendFileVO.setFileUrl(robotWelcome.getResourceUrl());
sendFileVO.setFileName(robotWelcome.getResourceName());
sendFileVO.setIp(ip);
sendFileVO.setAltId(robotWxId);
sendFileVO.setWxId(userWxId);
sendFileVO.setCode(SendMessageTypeEnum.SELF.getCode());
WxGroupSDK.sendFile(sendFileVO);
}
} }
//发送H5链接
String endUrl = wechatLinkPrefix + "/dialog" + "?book_group_id=" + 0 + "&wxId=" + userWxId + "&robotWxId=" + robotWxId;
String resultUrl = UrlUtils.getShortUrl4Own(endUrl);
String h5Content = "你可以通过点击" + resultUrl + ",或者输入【】内关键词唤醒我\n" + "小睿会在这里时时陪伴你";
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(h5Content);
sendTextMessageVO.setAltId(robotWxId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
WxGroupSDK.sendTextMessage(sendTextMessageVO);
} }
//发送H5链接 });
String endUrl = wechatLinkPrefix + "/dialog" + "?book_group_id=" + 0 + "&wxId=" + userWxId + "&robotWxId=" + robotWxId;
String resultUrl = UrlUtils.getShortUrl4Own(endUrl);
String h5Content = "你可以通过点击" + resultUrl + ",或者输入【】内关键词唤醒我\n" + "小睿会在这里时时陪伴你";
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(h5Content);
sendTextMessageVO.setAltId(robotWxId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}
} }
@Override @Override
......
...@@ -55,4 +55,7 @@ public class PcloudRobot extends BaseEntity { ...@@ -55,4 +55,7 @@ public class PcloudRobot extends BaseEntity {
@ApiModelProperty("编号") @ApiModelProperty("编号")
private String uniqueNumber; private String uniqueNumber;
@ApiModelProperty("欢迎语间隔时长")
private Integer welcomeDuration;
} }
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
<result column="state" property="state" jdbcType="INTEGER" /> <result column="state" property="state" jdbcType="INTEGER" />
<result column="wake_up" property="wakeUp" jdbcType="INTEGER" /> <result column="wake_up" property="wakeUp" jdbcType="INTEGER" />
<result column="unique_number" property="uniqueNumber" jdbcType="VARCHAR"/> <result column="unique_number" property="uniqueNumber" jdbcType="VARCHAR"/>
<result column="welcome_duration" property="welcomeDuration" jdbcType="INTEGER" />
</resultMap> </resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
id, wx_id, nick_name, head, qrcode_url, robot_type, keyword_classify_id, state, wake_up, unique_number id, wx_id, nick_name, head, qrcode_url, robot_type, keyword_classify_id, state, wake_up, unique_number,welcome_duration
</sql> </sql>
<insert id="insert" parameterType="PcloudRobot" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="PcloudRobot" useGeneratedKeys="true" keyProperty="id">
...@@ -27,7 +28,8 @@ ...@@ -27,7 +28,8 @@
keyword_classify_id, keyword_classify_id,
state, state,
wake_up, wake_up,
unique_number unique_number,
welcome_duration
) )
values ( values (
#{wxId,jdbcType=VARCHAR}, #{wxId,jdbcType=VARCHAR},
...@@ -38,7 +40,8 @@ ...@@ -38,7 +40,8 @@
#{keywordClassifyId,jdbcType=BIGINT}, #{keywordClassifyId,jdbcType=BIGINT},
#{state,jdbcType=INTEGER}, #{state,jdbcType=INTEGER},
#{wakeUp,jdbcType=INTEGER}, #{wakeUp,jdbcType=INTEGER},
#{uniqueNumber, jdbcType=VARCHAR} #{uniqueNumber, jdbcType=VARCHAR},
#{welcomeDuration, jdbcType=INTEGER}
) )
</insert> </insert>
...@@ -72,6 +75,9 @@ ...@@ -72,6 +75,9 @@
<if test="uniqueNumber != null"> <if test="uniqueNumber != null">
unique_number = #{uniqueNumber, jdbcType=VARCHAR}, unique_number = #{uniqueNumber, jdbcType=VARCHAR},
</if> </if>
<if test="welcomeDuration != null">
welcome_duration = #{welcomeDuration,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
...@@ -98,6 +104,7 @@ ...@@ -98,6 +104,7 @@
r.keyword_classify_id keywordClassifyId, r.keyword_classify_id keywordClassifyId,
r.state state, r.state state,
r.unique_number uniqueNumber, r.unique_number uniqueNumber,
r.welcome_duration welcomeDuration,
rc.classify_name classifyName rc.classify_name classifyName
FROM FROM
pcloud_robot r pcloud_robot r
......
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