Commit fea41be5 by 郑永强

Merge branch 'fix-zyq-1014150' into feat-zyq-1001743

# Conflicts:
#	pcloud-service-book/src/main/java/com/pcloud/book/adnews/biz/impl/AdNewsBizImpl.java
parents b9300210 34cdabdb
...@@ -91,6 +91,9 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -91,6 +91,9 @@ public class AdNewsBizImpl implements AdNewsBiz {
private static final String AD_EVENING_NEWS_SCHEDULE_PRE = "AD_EVENING_NEWS_SCHEDULE_"; private static final String AD_EVENING_NEWS_SCHEDULE_PRE = "AD_EVENING_NEWS_SCHEDULE_";
// 发送消息的长度限制
private static final Integer SEND_MESSAGE_LENGTH=300;
@Value("${wechat.group.link.prefix}") @Value("${wechat.group.link.prefix}")
private String wechatGroupLinkPrefix; private String wechatGroupLinkPrefix;
...@@ -297,7 +300,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -297,7 +300,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNews.setShortUrl(UrlUtils.getShortUrl4Own(transferUrl)); adNews.setShortUrl(UrlUtils.getShortUrl4Own(transferUrl));
} }
} }
// 将多条需要发送的早晚报拼接成300字符一组的消息 // 将多条需要发送的早晚报拼接成小于字数限制一组的消息
contents = this.concatContent(groupQrcodeFoAdDTO.getAdNewsList()); contents = this.concatContent(groupQrcodeFoAdDTO.getAdNewsList());
// 将对应群的消息发送出去 // 将对应群的消息发送出去
this.sendAdNewsToWechatGroup(adNewsSet, new ArrayList<GroupQrcodeFoAdDTO>() {{ this.sendAdNewsToWechatGroup(adNewsSet, new ArrayList<GroupQrcodeFoAdDTO>() {{
...@@ -442,6 +445,34 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -442,6 +445,34 @@ public class AdNewsBizImpl implements AdNewsBiz {
} }
/** /**
* 替换转义符
* @param adNewsList
*/
private void replaceUnescaped(List<AdNews> adNewsList) {
for (AdNews adNews : adNewsList) {
if (!StringUtil.isEmpty(adNews.getTitle())) {
adNews.setTitle(adNews.getTitle()
.replaceAll("&amp;quot;", "\"")
.replaceAll("&nbsp;", " "));
}
}
}
/**
* 替换转义符
* @param adNewsGroupRecordVOS
*/
private void replaceUnescaped4Record(List<AdNewsGroupRecordVO> adNewsGroupRecordVOS) {
for (AdNewsGroupRecordVO adNewsGroupRecordVO : adNewsGroupRecordVOS) {
if (!StringUtil.isEmpty(adNewsGroupRecordVO.getTitle())) {
adNewsGroupRecordVO.setTitle(adNewsGroupRecordVO.getTitle()
.replaceAll("&amp;quot;", "\"")
.replaceAll("&nbsp;", " "));
}
}
}
/**
* 将发送记录入库 * 将发送记录入库
* *
* @param adNewsGroupRecords * @param adNewsGroupRecords
...@@ -483,7 +514,23 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -483,7 +514,23 @@ public class AdNewsBizImpl implements AdNewsBiz {
String robotId = wechatGroupConsr.getRobotIdByGroupId(weixinGroupId); String robotId = wechatGroupConsr.getRobotIdByGroupId(weixinGroupId);
if (StringUtil.isEmpty(robotId)) { if (StringUtil.isEmpty(robotId)) {
LOGGER.info("发送编辑端早晚报未找到小号" + weixinGroupId); LOGGER.info("发送编辑端早晚报未找到小号" + weixinGroupId);
continue;
} }
// 如果正文内容的长度小于1,说明文字少于限制数,那么就可以合并发送
if(contents.size()==1){
String temp = contents.get(0);
if (!StringUtil.isEmpty(startContent)) { temp = startContent.concat("\n\n").concat(temp); }
if (!StringUtil.isEmpty(endContent)) { temp = temp.concat("\n").concat(endContent); }
// 合并后的字数长度小于限制则发送
if(temp.length() <= SEND_MESSAGE_LENGTH){
// 直接发送合并后的消息
sendAdNewsText(temp, robotId, weixinGroupId);
continue;
}
}
if (!StringUtil.isEmpty(startContent)) { if (!StringUtil.isEmpty(startContent)) {
//发送开场语 //发送开场语
sendAdNewsText(startContent, robotId, weixinGroupId); sendAdNewsText(startContent, robotId, weixinGroupId);
...@@ -519,10 +566,10 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -519,10 +566,10 @@ public class AdNewsBizImpl implements AdNewsBiz {
} }
/** /**
* 将内容拼接为300字符一条数据项的数组【微信目前单次消息发送字符长度为300 * 将内容拼接为 SEND_MESSAGE_LENGTH 字符一条数据项的数组【微信目前单次消息发送字符长度存在字数限制
* 拼接内容大致为 * 拼接内容大致为
* 1.xxxxxxxxxxx 2.xxxxxxxxxx 3.xxxxxxxx 【假设此条数据加下一条数据【4.xxx】 就大于300字符,那就先将之前的存一条到数组】 * 1.xxxxxxxxxxx 2.xxxxxxxxxx 3.xxxxxxxx 【假设此条数据加下一条数据【4.xxx】 就大于限制数,那就先将之前的存一条到数组】
* 4.xxxxx 5.xxxxxxx 【多余300字符再重新拼接,以此循环下去】 * 4.xxxxx 5.xxxxxxx 【多余限制数的字符再重新拼接,以此循环下去】
* *
* @param adNewsList * @param adNewsList
* @return * @return
...@@ -533,8 +580,8 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -533,8 +580,8 @@ public class AdNewsBizImpl implements AdNewsBiz {
int i = 1; int i = 1;
for (AdNews adNews : adNewsList) { for (AdNews adNews : adNewsList) {
String temp = content + i + "." + adNews.getTitle() + adNews.getShortUrl() + "\n"; String temp = content + i + "." + adNews.getTitle() + adNews.getShortUrl() + "\n";
if (temp.length() >= 1000) { if (temp.length() >= SEND_MESSAGE_LENGTH) {
// 如果本次拼接后的长度大于 300,那么将之前拼接的内容存入数组 // 如果本次拼接后的长度大于限制数,那么将之前拼接的内容存入数组
contents.add(content); contents.add(content);
// 重置 content 的内容 // 重置 content 的内容
content = i + "." + adNews.getTitle() + adNews.getShortUrl() + "\n"; content = i + "." + adNews.getTitle() + adNews.getShortUrl() + "\n";
...@@ -611,6 +658,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -611,6 +658,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
map.put("adNewsWechatIds", adNewsListParam.getAdNewsWechatIds()); map.put("adNewsWechatIds", adNewsListParam.getAdNewsWechatIds());
map.put("contentFrom", adNewsListParam.getContentFrom()); map.put("contentFrom", adNewsListParam.getContentFrom());
PageBeanNew<AdNews> pageBeanNew = adNewsDao.listPageNew(pageParam, map, "getAdNewsList"); PageBeanNew<AdNews> pageBeanNew = adNewsDao.listPageNew(pageParam, map, "getAdNewsList");
this.replaceUnescaped(pageBeanNew.getRecordList());
return pageBeanNew; return pageBeanNew;
} }
...@@ -812,7 +860,9 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -812,7 +860,9 @@ public class AdNewsBizImpl implements AdNewsBiz {
@Override @Override
@ParamLog("查询早晚报发送详情") @ParamLog("查询早晚报发送详情")
public List<AdNewsGroupRecordVO> getAdNewsGroupRecord(Long partyId, Long messageStatisticId) { public List<AdNewsGroupRecordVO> getAdNewsGroupRecord(Long partyId, Long messageStatisticId) {
return adNewsGroupRecordDao.getAdNewsGroupRecord(partyId, messageStatisticId); List<AdNewsGroupRecordVO> adNewsGroupRecordVOS= adNewsGroupRecordDao.getAdNewsGroupRecord(partyId, messageStatisticId);
this.replaceUnescaped4Record(adNewsGroupRecordVOS);
return adNewsGroupRecordVOS;
} }
@Override @Override
......
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