Commit aa3646c9 by zhangdongwei-intern

衔接语链接替换

parent 7ad99d18
...@@ -105,8 +105,10 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -105,8 +105,10 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
private String wechatLinkPrefix; private String wechatLinkPrefix;
private final static String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE = "${PROGRESS_URL}"; private final static String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE = "${PROGRESS_URL}";
//需求单链接替换符
private final static String PERSONAL_STAGE_PAPER_TEMPLATE = "${PROGRESS_URL&ProgressId}"; private final static String PERSONAL_STAGE_PAPER_TEMPLATE = "${PROGRESS_URL&ProgressId}";
//需求单链接替换符
private final static String PERSONAL_STAGE_PAPER_TEMPLATE1 = "${PROGRESS_URL&ProgressId}";
// 项目进度路由 // 项目进度路由
private final static String PERSONAL_STAGE_PROJECT_PROGRESS = "/personalCenter/projectProgress"; private final static String PERSONAL_STAGE_PROJECT_PROGRESS = "/personalCenter/projectProgress";
...@@ -531,9 +533,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -531,9 +533,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
return; return;
} }
//替换需求定制单链接 //替换需求定制单链接
if (null != personalStageReply.getPaperId()) { this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId());
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId());
}
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId); sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
} }
...@@ -556,13 +556,19 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -556,13 +556,19 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog("替换需求定制单链接") @ParamLog("替换需求定制单链接")
private void replacePaperUrl(List<PersonalStageReplyItem> items, String robotId, String userWxId, Long paperId){ private void replacePaperUrl(List<PersonalStageReplyItem> items, String robotId, String userWxId, Long paperId){
if (null == paperId){
return;
}
for (PersonalStageReplyItem item : items){ for (PersonalStageReplyItem item : items){
if(ReplyTypeEnum.TEXT.value.equals(item.getReplyType())){ if(ReplyTypeEnum.TEXT.value.equals(item.getReplyType())){
if (null == paperId){
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, ""));
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, ""));
return;
}
String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PAPER).concat(paperId.toString()).concat("&wxId=" + userWxId + "&robotWxId=" + robotId); String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PAPER).concat(paperId.toString()).concat("&wxId=" + userWxId + "&robotWxId=" + robotId);
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, UrlUtils.getShortUrl4Own(longUrl))); //由于前端给的替换符中的“&”可能会是“&amp;”,所以两种替换符都要换掉
String shortLink = UrlUtils.getShortUrl4Own(longUrl);
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, shortLink));
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, shortLink));
} }
} }
} }
......
...@@ -42,6 +42,7 @@ import com.pcloud.common.page.PageParam; ...@@ -42,6 +42,7 @@ import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateNewUtils; import com.pcloud.common.utils.DateNewUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil; import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.wechatgroup.group.dto.GroupRobotDTO; import com.pcloud.wechatgroup.group.dto.GroupRobotDTO;
import com.pcloud.wechatgroup.group.dto.GroupUserDTO; import com.pcloud.wechatgroup.group.dto.GroupUserDTO;
...@@ -98,6 +99,15 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -98,6 +99,15 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
@Value("${system.env}") @Value("${system.env}")
private String envStr; private String envStr;
@Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix;
//需求单链接替换符
private final static String PERSONAL_STAGE_PAPER_TEMPLATE = "${PROGRESS_URL&amp;ProgressId}";
//需求单链接替换符
private final static String PERSONAL_STAGE_PAPER_TEMPLATE1 = "${PROGRESS_URL&ProgressId}";
//需求定制单路由 https://wechat666.raysgo.com/personalCenter/questionNaire?paperId=679
private final static String PERSONAL_STAGE_PAPER = "/personalCenter/questionNaire?paperId=";
@Override @Override
@ParamLog("新增阶段跳转") @ParamLog("新增阶段跳转")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -375,6 +385,10 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -375,6 +385,10 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
LOGGER.info("没有该跳转衔接语!"); LOGGER.info("没有该跳转衔接语!");
return; return;
} }
List<PersonalStageJumpLinkup> list = new ArrayList<>();
list.add(jumpLinkup);
this.replacePaperUrl(list, linkupDelayDTO.getRobotId(), linkupDelayDTO.getWxId(), jumpLinkup.getPersonalStageJumpId());
jumpLinkup = list.get(0);
if(ReplyTypeEnum.TEXT.value.equals( jumpLinkup.getReplyType())){ if(ReplyTypeEnum.TEXT.value.equals( jumpLinkup.getReplyType())){
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO(); SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(personalStageBiz.replaceProjectProgressUrl(jumpLinkup.getLinkupContent(),linkupDelayDTO.getRobotId(),linkupDelayDTO.getWxId(),linkupDelayDTO.getPersonalStageUserId())); sendTextMessageVO.setContent(personalStageBiz.replaceProjectProgressUrl(jumpLinkup.getLinkupContent(),linkupDelayDTO.getRobotId(),linkupDelayDTO.getWxId(),linkupDelayDTO.getPersonalStageUserId()));
...@@ -547,6 +561,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -547,6 +561,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
if(ListUtils.isEmpty(linkups)){ if(ListUtils.isEmpty(linkups)){
return; return;
} }
this.replacePaperUrl(linkups, robotWxId, userWxId, jumpId);
for (PersonalStageJumpLinkup jumpLinkup : linkups){ for (PersonalStageJumpLinkup jumpLinkup : linkups){
if (jumpLinkup.getToStageStartTime()!=null&&jumpLinkup.getToStageStartTime()>0){ if (jumpLinkup.getToStageStartTime()!=null&&jumpLinkup.getToStageStartTime()>0){
LinkupDelayDTO linkupDelayDTO=new LinkupDelayDTO(); LinkupDelayDTO linkupDelayDTO=new LinkupDelayDTO();
...@@ -588,4 +603,30 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -588,4 +603,30 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
updateStageUser.setUpdateTime(new Date()); updateStageUser.setUpdateTime(new Date());
personalStageUserDao.update(updateStageUser); personalStageUserDao.update(updateStageUser);
} }
@ParamLog("替换需求定制单链接")
private void replacePaperUrl(List<PersonalStageJumpLinkup> linkups, String robotId, String userWxId, Long jumpId){
PersonalStageJumpDto stageJump = personalStageJumpDao.getDtoById(jumpId);
if (null == stageJump){
return;
}
PersonalStage personalStage = personalStageDao.getById(stageJump.getPersonalStageId());
if (null == personalStage){
return;
}
for (PersonalStageJumpLinkup linkup : linkups){
if(ReplyTypeEnum.TEXT.value.equals(linkup.getReplyType())){
if (null == personalStage.getPaperId()){
linkup.setLinkupContent(linkup.getLinkupContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, ""));
linkup.setLinkupContent(linkup.getLinkupContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, ""));
continue;
}
String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PAPER).concat(personalStage.getPaperId().toString()).concat("&wxId=" + userWxId + "&robotWxId=" + robotId);
//由于前端给的替换符中的“&”可能会是“&amp;”,所以两种替换符都要换掉
String shortLink = UrlUtils.getShortUrl4Own(longUrl);
linkup.setLinkupContent(linkup.getLinkupContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, shortLink));
linkup.setLinkupContent(linkup.getLinkupContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE1, shortLink));
}
}
}
} }
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