Commit e1b475e8 by 裴大威

Merge branch 'opti-getSkillDetail' into 'master'

optimize getSkillDetail

See merge request rays/pcloud-book!545
parents a8c4f034 76caf5f5
...@@ -88,6 +88,8 @@ import java.util.Date; ...@@ -88,6 +88,8 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -154,6 +156,8 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz { ...@@ -154,6 +156,8 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
@Autowired @Autowired
private PcloudSkillRecordDao pcloudSkillRecordDao; private PcloudSkillRecordDao pcloudSkillRecordDao;
private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(5);
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -686,49 +690,53 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz { ...@@ -686,49 +690,53 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
} }
} }
//新增技能获取记录
PcloudSkillRecord pcloudSkillRecord = pcloudSkillRecordDao.getBySkillIdAndWxId(skillId, wxUserId); //异步插入记录
if (null == pcloudSkillRecord) { EXECUTOR_SERVICE.execute(() ->{
PcloudSkillRecord pcloudSkillRecordNew = new PcloudSkillRecord(); //新增技能获取记录
if (SkillTypeEnum.TIME_MANAGE.value == type){ PcloudSkillRecord pcloudSkillRecord = pcloudSkillRecordDao.getBySkillIdAndWxId(skillId, wxUserId);
//先查询订阅状态 if (null == pcloudSkillRecord) {
TimeControlTaskSubscribe timeControlTaskSubscribe = taskSubscribeBiz.getSubscribeState(wxUserId,relSkillId); PcloudSkillRecord pcloudSkillRecordNew = new PcloudSkillRecord();
if (null != timeControlTaskSubscribe){ if (SkillTypeEnum.TIME_MANAGE.value == type){
pcloudSkillRecordNew.setState(timeControlTaskSubscribe.getState()); //先查询订阅状态
}else { TimeControlTaskSubscribe timeControlTaskSubscribe = taskSubscribeBiz.getSubscribeState(wxUserId,relSkillId);
if (null != timeControlTaskSubscribe){
pcloudSkillRecordNew.setState(timeControlTaskSubscribe.getState());
}else {
pcloudSkillRecordNew.setState(0);
}
}else if (SkillTypeEnum.READING.value == type || SkillTypeEnum.RESOURCE.value == type){
pcloudSkillRecordNew.setState(0); pcloudSkillRecordNew.setState(0);
} }
}else if (SkillTypeEnum.READING.value == type || SkillTypeEnum.RESOURCE.value == type){ pcloudSkillRecordNew.setRobotWxId(robotWxId);
pcloudSkillRecordNew.setState(0); pcloudSkillRecordNew.setWxUserId(wxUserId);
} pcloudSkillRecordNew.setSkillId(skillId);
pcloudSkillRecordNew.setRobotWxId(robotWxId); pcloudSkillRecordNew.setSkillType(type);
pcloudSkillRecordNew.setWxUserId(wxUserId); pcloudSkillRecordNew.setCreateTime(new Date());
pcloudSkillRecordNew.setSkillId(skillId); pcloudSkillRecordNew.setUpdateTime(new Date());
pcloudSkillRecordNew.setSkillType(type); pcloudSkillRecordDao.insertSelective(pcloudSkillRecordNew);
pcloudSkillRecordNew.setCreateTime(new Date()); }else {
pcloudSkillRecordNew.setUpdateTime(new Date()); if (SkillTypeEnum.TIME_MANAGE.value == type){
pcloudSkillRecordDao.insertSelective(pcloudSkillRecordNew); if (SubTypeEnum.CANCEL.value == pcloudSkillRecord.getState()){
}else { pcloudSkillRecord.setState(0);
if (SkillTypeEnum.TIME_MANAGE.value == type){ }
if (SubTypeEnum.CANCEL.value == pcloudSkillRecord.getState()){
pcloudSkillRecord.setState(0);
} }
pcloudSkillRecord.setUpdateTime(new Date());
pcloudSkillRecordDao.updateByPrimaryKeySelective(pcloudSkillRecord);
} }
pcloudSkillRecord.setUpdateTime(new Date()); PcloudSubRemind pcloudSubRemind = pcloudSubRemindDao.getByMap(relSkillId, type, wxUserId, skillId);
pcloudSkillRecordDao.updateByPrimaryKeySelective(pcloudSkillRecord); if(null==pcloudSubRemind) {
} PcloudSubRemind subRemind = new PcloudSubRemind();
PcloudSubRemind pcloudSubRemind = pcloudSubRemindDao.getByMap(relSkillId, type, wxUserId, skillId); subRemind.setCreateTime(new Date());
if(null==pcloudSubRemind) { subRemind.setRelSkillId(relSkillId);
PcloudSubRemind subRemind = new PcloudSubRemind(); subRemind.setRobotWxId(robotWxId);
subRemind.setCreateTime(new Date()); subRemind.setSkillType(type);
subRemind.setRelSkillId(relSkillId); subRemind.setSubscribeState(0);
subRemind.setRobotWxId(robotWxId); subRemind.setWxUserId(wxUserId);
subRemind.setSkillType(type); subRemind.setSkillId(Long.valueOf(skillId));
subRemind.setSubscribeState(0); pcloudSubRemindDao.insert(subRemind);
subRemind.setWxUserId(wxUserId); }
subRemind.setSkillId(Long.valueOf(skillId)); });
pcloudSubRemindDao.insert(subRemind);
}
if (null != robotSkillDetail) { if (null != robotSkillDetail) {
String filterStr = StringUtilParent.replaceHtml(robotSkillDetail.getRelSkillIntroduce()); String filterStr = StringUtilParent.replaceHtml(robotSkillDetail.getRelSkillIntroduce());
......
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