1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

Fix AgentServiceProxy

This commit is contained in:
dengchao@xgtl 2020-04-16 11:42:49 +08:00
parent 9b5667d602
commit 8c357cf8fe

View File

@ -25,71 +25,69 @@ import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.*; import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.util.mobile.MobileAddress; import com.chatopera.cc.util.mobile.MobileAddress;
import com.chatopera.cc.util.mobile.MobileNumberUtils; import com.chatopera.cc.util.mobile.MobileNumberUtils;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.util.List; import java.util.List;
import java.util.Optional;
@Component @Component
@RequiredArgsConstructor
public class AgentServiceProxy { public class AgentServiceProxy {
private final static Logger logger = LoggerFactory.getLogger(AgentServiceProxy.class); private final static Logger logger = LoggerFactory.getLogger(AgentServiceProxy.class);
@Autowired @NonNull
private AgentServiceRepository agentServiceRes; private final AgentServiceRepository agentServiceRes;
@Autowired @NonNull
private AgentUserContactsRepository agentUserContactsRes; private final AgentUserContactsRepository agentUserContactsRes;
@Autowired @NonNull
private SNSAccountRepository snsAccountRes; private final SNSAccountRepository snsAccountRes;
@Autowired @NonNull
private WeiXinUserRepository weiXinUserRes; private final WeiXinUserRepository weiXinUserRes;
@Autowired @NonNull
private OnlineUserRepository onlineUserRes; private final OnlineUserRepository onlineUserRes;
@Autowired @NonNull
private PbxHostRepository pbxHostRes; private final PbxHostRepository pbxHostRes;
@Autowired @NonNull
private StatusEventRepository statusEventRes; private final StatusEventRepository statusEventRes;
@Autowired @NonNull
private ServiceSummaryRepository serviceSummaryRes; private final ServiceSummaryRepository serviceSummaryRes;
@Autowired @NonNull
private TagRepository tagRes; private final TagRepository tagRes;
@Autowired @NonNull
private QuickTypeRepository quickTypeRes; private final QuickTypeRepository quickTypeRes;
@Autowired @NonNull
private QuickReplyRepository quickReplyRes; private final QuickReplyRepository quickReplyRes;
@Autowired @NonNull
private TagRelationRepository tagRelationRes; private final TagRelationRepository tagRelationRes;
@Autowired @NonNull
private ChatMessageRepository chatMessageRepository; private final ChatMessageRepository chatMessageRepository;
@Autowired @NonNull
private ContactsRepository contactsRes; private final ContactsRepository contactsRes;
/** /**
* 关联关系 * 关联关系
*
* @param agentno
* @param orgi
* @param agentService
* @param map
*/ */
public void processRelaData( public void processRelaData(
final String agentno, final String agentno,
@ -155,8 +153,9 @@ public class AgentServiceProxy {
view.addObject("weiXinUser", weiXinUser); view.addObject("weiXinUser", weiXinUser);
} }
} else if (MainContext.ChannelType.WEBIM.toString().equals(agentUser.getChannel())) { } else if (MainContext.ChannelType.WEBIM.toString().equals(agentUser.getChannel())) {
OnlineUser onlineUser = onlineUserRes.findOne(agentUser.getUserid()); Optional<OnlineUser> optional = onlineUserRes.findById(agentUser.getUserid());
if (onlineUser != null) { if (optional.isPresent()) {
OnlineUser onlineUser = optional.get();
if (StringUtils.equals( if (StringUtils.equals(
MainContext.OnlineUserStatusEnum.OFFLINE.toString(), onlineUser.getStatus())) { MainContext.OnlineUserStatusEnum.OFFLINE.toString(), onlineUser.getStatus())) {
onlineUser.setBetweentime( onlineUser.setBetweentime(
@ -185,12 +184,6 @@ public class AgentServiceProxy {
/** /**
* 组装AgentUser的相关信息并封装在ModelView中 * 组装AgentUser的相关信息并封装在ModelView中
*
* @param view
* @param map
* @param agentUser
* @param orgi
* @param logined
*/ */
public void bundleDialogRequiredDataInView( public void bundleDialogRequiredDataInView(
final ModelAndView view, final ModelAndView view,
@ -207,7 +200,7 @@ public class AgentServiceProxy {
} }
// 客服设置 // 客服设置
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAppid())) { if (StringUtils.isNotBlank(agentUser.getAppid())) {
view.addObject("inviteData", OnlineUserProxy.consult(agentUser.getAppid(), orgi)); view.addObject("inviteData", OnlineUserProxy.consult(agentUser.getAppid(), orgi));
// 服务小结 // 服务小结
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
@ -228,9 +221,12 @@ public class AgentServiceProxy {
// 坐席服务记录 // 坐席服务记录
AgentService agentService = null; AgentService agentService = null;
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
agentService = agentServiceRes.findOne(agentUser.getAgentserviceid()); Optional<AgentService> optional = agentServiceRes.findById(agentUser.getAgentserviceid());
view.addObject("curAgentService", agentService); if (optional.isPresent()) {
/** agentService = optional.get();
view.addObject("curAgentService", agentService);
}
/*
* 获取关联数据 * 获取关联数据
*/ */
if (agentService != null) { if (agentService != null) {
@ -243,11 +239,10 @@ public class AgentServiceProxy {
attacheChannelInfo(view, agentUser, agentService, logined); attacheChannelInfo(view, agentUser, agentService, logined);
// 标签快捷回复等 // 标签快捷回复等
view.addObject("serviceCount", Integer view.addObject("serviceCount", agentServiceRes
.valueOf(agentServiceRes .countByUseridAndOrgiAndStatus(agentUser
.countByUseridAndOrgiAndStatus(agentUser .getUserid(), logined.getOrgi(),
.getUserid(), logined.getOrgi(), MainContext.AgentUserStatusEnum.END.toString()));
MainContext.AgentUserStatusEnum.END.toString())));
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid())); view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
} }