1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-05 20:41:34 +08:00

Fix AgentServiceRepository related class

This commit is contained in:
dengchao@xgtl 2020-04-17 15:03:47 +08:00
parent 6064584884
commit e463139cc2
6 changed files with 461 additions and 492 deletions

View File

@ -20,39 +20,39 @@ import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.model.AgentService; import com.chatopera.cc.model.AgentService;
import com.chatopera.cc.model.AgentUser; import com.chatopera.cc.model.AgentUser;
import com.chatopera.cc.persistence.repository.AgentServiceRepository; import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.springframework.lang.NonNull;
import org.slf4j.LoggerFactory; import org.springframework.lang.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
@Slf4j
@Component @Component
@RequiredArgsConstructor
public class ACDChatbotService { public class ACDChatbotService {
private final static Logger logger = LoggerFactory.getLogger(ACDChatbotService.class);
@Autowired @NonNull
private AgentServiceRepository agentServiceRes; private final AgentServiceRepository agentServiceRes;
/** /**
* 为访客分配机器人客服 ACD策略此处 AgentStatus 是建议 坐席 如果启用了 历史服务坐席 优先策略 则会默认检查历史坐席是否空闲如果空闲则分配如果不空闲 分配当前建议的坐席 * 为访客分配机器人客服 ACD策略此处 AgentStatus 是建议 坐席 如果启用了 历史服务坐席 优先策略 则会默认检查历史坐席是否空闲如果空闲则分配如果不空闲 分配当前建议的坐席
*
* @param agentUser
* @param orgi
* @return
* @throws Exception
*/ */
@Nullable
public AgentService processChatbotService(final String botName, final AgentUser agentUser, final String orgi) { public AgentService processChatbotService(final String botName, final AgentUser agentUser, final String orgi) {
AgentService agentService = new AgentService(); //放入缓存的对象 AgentService agentService = new AgentService(); //放入缓存的对象
Date now = new Date(); Date now = new Date();
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
agentService = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi); agentService = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi);
agentService.setEndtime(now); if (agentService != null) {
if (agentService.getServicetime() != null) { agentService.setEndtime(now);
agentService.setSessiontimes(System.currentTimeMillis() - agentService.getServicetime().getTime()); if (agentService.getServicetime() != null) {
agentService.setSessiontimes(System.currentTimeMillis() - agentService.getServicetime().getTime());
}
agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
} }
agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
} else { } else {
agentService.setServicetime(now); agentService.setServicetime(now);
agentService.setLogindate(now); agentService.setLogindate(now);
@ -81,7 +81,9 @@ public class ACDChatbotService {
agentService.setLeavemsg(false); agentService.setLeavemsg(false);
} }
agentServiceRes.save(agentService); if (agentService != null) {
agentServiceRes.save(agentService);
}
return agentService; return agentService;
} }

View File

@ -23,22 +23,19 @@ import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.RestResult; import com.chatopera.cc.util.RestResult;
import com.chatopera.cc.util.RestResultType; import com.chatopera.cc.util.RestResultType;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
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.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -47,33 +44,26 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/api/leavemsg") @RequestMapping("/api/leavemsg")
@RequiredArgsConstructor
public class ApiLeavemsgController extends Handler { public class ApiLeavemsgController extends Handler {
@Autowired @NonNull
private AgentServiceRepository agentServiceRepository; private final AgentServiceRepository agentServiceRepository;
/** /**
* 获取留言列表 * 获取留言列表
*
* @param request
* @param username 搜索用户名精确搜索
* @return
*/ */
@RequestMapping("/list") @RequestMapping("/list")
@Menu(type = "apps", subtype = "app", access = true) @Menu(type = "apps", subtype = "app", access = true)
public ResponseEntity<RestResult> list(HttpServletRequest request, @RequestBody RequestValues<AgentService> values) { public ResponseEntity<RestResult> list(@RequestBody RequestValues<AgentService> values) {
Page<AgentService> page = agentServiceRepository.findAll(new Specification<AgentService>() { Page<AgentService> page = agentServiceRepository.findAll((Specification<AgentService>) (root, query, cb) -> {
@Override List<Predicate> list = new ArrayList<>();
public Predicate toPredicate(Root<AgentService> root, CriteriaQuery<?> query, list.add(cb.equal(root.get("leavemsg").as(Boolean.class), true));
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
list.add(cb.equal(root.get("leavemsg").as(Boolean.class), true));
list.add(cb.equal(root.get("leavemsgstatus").as(String.class), MainContext.LeaveMsgStatus.NOTPROCESS.toString())); list.add(cb.equal(root.get("leavemsgstatus").as(String.class), MainContext.LeaveMsgStatus.NOTPROCESS.toString()));
Predicate[] p = new Predicate[list.size()]; Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p)); return cb.and(list.toArray(p));
}
}, PageRequest.of(super.getP(values.getQuery()), super.getPs(values.getQuery()), Sort.Direction.DESC, "createtime")); }, PageRequest.of(super.getP(values.getQuery()), super.getPs(values.getQuery()), Sort.Direction.DESC, "createtime"));
return new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK); return new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK);
} }

View File

@ -23,23 +23,20 @@ import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.RestResult; import com.chatopera.cc.util.RestResult;
import com.chatopera.cc.util.RestResultType; import com.chatopera.cc.util.RestResultType;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
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.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -49,31 +46,24 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/api/quality") @RequestMapping("/api/quality")
@RequiredArgsConstructor
public class ApiQualityController extends Handler { public class ApiQualityController extends Handler {
@Autowired @NonNull
private AgentServiceRepository agentServiceRepository; private final AgentServiceRepository agentServiceRepository;
/** /**
* 获取质检列表 * 获取质检列表
*
* @param request
* @param username 搜索用户名精确搜索
* @return
*/ */
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
@Menu(type = "apps", subtype = "app", access = true) @Menu(type = "apps", subtype = "app", access = true)
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid AgentService agentService, @Valid String begin, @Valid String end) { public ResponseEntity<RestResult> list(HttpServletRequest request) {
Page<AgentService> page = agentServiceRepository.findAll(new Specification<AgentService>() { Page<AgentService> page = agentServiceRepository.findAll((Specification<AgentService>) (root, query, cb) -> {
@Override List<Predicate> list = new ArrayList<>();
public Predicate toPredicate(Root<AgentService> root, CriteriaQuery<?> query, list.add((cb.equal(root.get("qualitystatus").as(String.class), MainContext.QualityStatusEnum.NODIS.toString())));
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
list.add((cb.equal(root.get("qualitystatus").as(String.class), MainContext.QualityStatusEnum.NODIS.toString())));
Predicate[] p = new Predicate[list.size()]; Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p)); return cb.and(list.toArray(p));
}
}, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime")); }, PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
return new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK); return new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK);
} }

View File

@ -20,27 +20,27 @@ import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.AgentService; import com.chatopera.cc.model.AgentService;
import com.chatopera.cc.persistence.repository.AgentServiceRepository; import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.Menu;
import org.springframework.beans.factory.annotation.Autowired; import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller @Controller
@RequestMapping("/service") @RequestMapping("/service")
public class CommentController extends Handler{ @RequiredArgsConstructor
@Autowired public class CommentController extends Handler {
private AgentServiceRepository agentServiceRes ; @NonNull
private final AgentServiceRepository agentServiceRes;
@RequestMapping("/comment/index") @RequestMapping("/comment/index")
@Menu(type = "service" , subtype = "comment" , admin= true) @Menu(type = "service", subtype = "comment", admin = true)
public ModelAndView index(ModelMap map , HttpServletRequest request , String userid , String agentservice , @Valid String channel) { public ModelAndView index(ModelMap map, HttpServletRequest request) {
Page<AgentService> agentServiceList = agentServiceRes.findByOrgiAndSatisfaction(super.getOrgi(request), true, PageRequest.of(super.getP(request), super.getPs(request))); Page<AgentService> agentServiceList = agentServiceRes.findByOrgiAndSatisfaction(super.getOrgi(request), true, PageRequest.of(super.getP(request), super.getPs(request)));
map.addAttribute("serviceList", agentServiceList); map.addAttribute("serviceList", agentServiceList);
return request(super.createAppsTempletResponse("/apps/service/comment/index")); return request(super.createAppsTempletResponse("/apps/service/comment/index"));

View File

@ -21,10 +21,6 @@ import com.chatopera.cc.acd.ACDVisitorDispatcher;
import com.chatopera.cc.acd.basic.ACDComposeContext; import com.chatopera.cc.acd.basic.ACDComposeContext;
import com.chatopera.cc.acd.basic.ACDMessageHelper; import com.chatopera.cc.acd.basic.ACDMessageHelper;
import com.chatopera.cc.basic.MainContext; import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainContext.CallType;
import com.chatopera.cc.basic.MainContext.ChannelType;
import com.chatopera.cc.basic.MainContext.MessageType;
import com.chatopera.cc.basic.MainContext.ReceiverType;
import com.chatopera.cc.basic.MainUtils; import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.model.Contacts; import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.CousultInvite; import com.chatopera.cc.model.CousultInvite;
@ -34,7 +30,6 @@ import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.socketio.client.NettyClients; import com.chatopera.cc.socketio.client.NettyClients;
import com.chatopera.cc.socketio.message.AgentStatusMessage; import com.chatopera.cc.socketio.message.AgentStatusMessage;
import com.chatopera.cc.socketio.message.ChatMessage; import com.chatopera.cc.socketio.message.ChatMessage;
import com.chatopera.cc.socketio.message.Message;
import com.chatopera.cc.socketio.util.HumanUtils; import com.chatopera.cc.socketio.util.HumanUtils;
import com.chatopera.cc.socketio.util.IMServiceUtils; import com.chatopera.cc.socketio.util.IMServiceUtils;
import com.chatopera.cc.util.IP; import com.chatopera.cc.util.IP;
@ -50,24 +45,42 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Date;
@SuppressWarnings("unused")
public class IMEventHandler { public class IMEventHandler {
private final static Logger logger = LoggerFactory.getLogger(IMEventHandler.class); private static final Logger logger = LoggerFactory.getLogger(IMEventHandler.class);
private static AgentUserProxy agentUserProxy;
private static AgentServiceRepository agentServiceRepository;
private static ACDVisitorDispatcher acdVisitorDispatcher;
protected SocketIOServer server; protected SocketIOServer server;
public IMEventHandler(SocketIOServer server) { public IMEventHandler(SocketIOServer server) {
this.server = server; this.server = server;
} }
static private AgentUserProxy agentUserProxy; private static AgentUserProxy getAgentUserProxy() {
static private AgentServiceRepository agentServiceRepository; if (agentUserProxy == null) {
static private ACDVisitorDispatcher acdVisitorDispatcher; agentUserProxy = MainContext.getContext().getBean(AgentUserProxy.class);
}
return agentUserProxy;
}
private static AgentServiceRepository getAgentServiceRepository() {
if (agentServiceRepository == null) {
agentServiceRepository = MainContext.getContext().getBean(AgentServiceRepository.class);
}
return agentServiceRepository;
}
private static ACDVisitorDispatcher getAcdVisitorDispatcher() {
if (acdVisitorDispatcher == null) {
acdVisitorDispatcher = MainContext.getContext().getBean(ACDVisitorDispatcher.class);
}
return acdVisitorDispatcher;
}
/** /**
* 接入访客并未访客寻找坐席服务人员 * 接入访客并未访客寻找坐席服务人员
*
* @param client
*/ */
@OnConnect @OnConnect
public void onConnect(SocketIOClient client) { public void onConnect(SocketIOClient client) {
@ -114,12 +127,12 @@ public class IMEventHandler {
InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress(); InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress();
String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()); String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString());
/** /*
* 加入到 缓存列表 * 加入到 缓存列表
*/ */
NettyClients.getInstance().putIMEventClient(user, client); NettyClients.getInstance().putIMEventClient(user, client);
/** /*
* 更新坐席服务类型 * 更新坐席服务类型
*/ */
IMServiceUtils.shiftOpsType(user, orgi, MainContext.OptType.HUMAN); IMServiceUtils.shiftOpsType(user, orgi, MainContext.OptType.HUMAN);
@ -129,7 +142,7 @@ public class IMEventHandler {
ipdata = IPTools.getInstance().findGeography(ip); ipdata = IPTools.getInstance().findGeography(ip);
} }
/** /*
* 用户进入到对话连接 排队用户请求 , 如果返回失败 * 用户进入到对话连接 排队用户请求 , 如果返回失败
* 表示当前坐席全忙用户进入排队状态当前提示信息 显示 当前排队的队列位置 * 表示当前坐席全忙用户进入排队状态当前提示信息 显示 当前排队的队列位置
* 不可进行对话用户发送的消息作为留言处理 * 不可进行对话用户发送的消息作为留言处理
@ -175,13 +188,11 @@ public class IMEventHandler {
logger.info("[onDisconnect] user {}, orgi {}", user, orgi); logger.info("[onDisconnect] user {}, orgi {}", user, orgi);
if (user != null) { if (user != null) {
try { try {
/** /*
* 用户主动断开服务 * 用户主动断开服务
*/ */
MainContext.getCache().findOneAgentUserByUserIdAndOrgi(user, orgi).ifPresent(p -> { MainContext.getCache().findOneAgentUserByUserIdAndOrgi(user, orgi)
ACDServiceRouter.getAcdAgentService().finishAgentService(p .ifPresent(p -> ACDServiceRouter.getAcdAgentService().finishAgentService(p, orgi));
, orgi);
});
} catch (Exception e) { } catch (Exception e) {
logger.warn("[onDisconnect] error", e); logger.warn("[onDisconnect] error", e);
} }
@ -228,7 +239,7 @@ public class IMEventHandler {
if (data.getType() == null) { if (data.getType() == null) {
data.setType("message"); data.setType("message");
} }
/** /*
* 以下代码主要用于检查 访客端的字数限制 * 以下代码主要用于检查 访客端的字数限制
*/ */
CousultInvite invite = OnlineUserProxy.consult(data.getAppid(), data.getOrgi()); CousultInvite invite = OnlineUserProxy.consult(data.getAppid(), data.getOrgi());
@ -242,32 +253,11 @@ public class IMEventHandler {
// else if (StringUtils.isNotBlank(data.getMessage()) && dataLength > 600) { // else if (StringUtils.isNotBlank(data.getMessage()) && dataLength > 600) {
// data.setMessage(data.getMessage().substring(0, 600)); // data.setMessage(data.getMessage().substring(0, 600));
// } // }
/** /*
* 处理表情 * 处理表情
*/ */
data.setMessage(MainUtils.processEmoti(data.getMessage())); data.setMessage(MainUtils.processEmoti(data.getMessage()));
HumanUtils.processMessage(data, data.getUserid()); HumanUtils.processMessage(data, data.getUserid());
} }
private static AgentUserProxy getAgentUserProxy() {
if (agentUserProxy == null) {
agentUserProxy = MainContext.getContext().getBean(AgentUserProxy.class);
}
return agentUserProxy;
}
private static AgentServiceRepository getAgentServiceRepository() {
if (agentServiceRepository == null) {
agentServiceRepository = MainContext.getContext().getBean(AgentServiceRepository.class);
}
return agentServiceRepository;
}
private static ACDVisitorDispatcher getAcdVisitorDispatcher() {
if (acdVisitorDispatcher == null) {
acdVisitorDispatcher = MainContext.getContext().getBean(ACDVisitorDispatcher.class);
}
return acdVisitorDispatcher;
}
} }

View File

@ -30,6 +30,8 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Optional;
public class HumanUtils { public class HumanUtils {
private final static Logger logger = LoggerFactory.getLogger(HumanUtils.class); private final static Logger logger = LoggerFactory.getLogger(HumanUtils.class);
private static AgentServiceRepository agentServiceRes; private static AgentServiceRepository agentServiceRes;
@ -37,9 +39,6 @@ public class HumanUtils {
/** /**
* 发送文本消息 * 发送文本消息
*
* @param data
* @param userid
*/ */
public static void processMessage(ChatMessage data, String userid) { public static void processMessage(ChatMessage data, String userid) {
processMessage(data, MainContext.MediaType.TEXT.toString(), userid); processMessage(data, MainContext.MediaType.TEXT.toString(), userid);
@ -47,10 +46,6 @@ public class HumanUtils {
/** /**
* 发送各种消息的底层方法 * 发送各种消息的底层方法
*
* @param chatMessage
* @param msgtype
* @param userid
*/ */
protected static void processMessage(final ChatMessage chatMessage, final String msgtype, final String userid) { protected static void processMessage(final ChatMessage chatMessage, final String msgtype, final String userid) {
logger.info("[processMessage] userid {}, msgtype {}", userid, msgtype); logger.info("[processMessage] userid {}, msgtype {}", userid, msgtype);
@ -59,7 +54,7 @@ public class HumanUtils {
Message outMessage = new Message(); Message outMessage = new Message();
/** /*
* 访客的昵称 * 访客的昵称
*/ */
// TODO 确定该值代表访客昵称 // TODO 确定该值代表访客昵称
@ -67,10 +62,12 @@ public class HumanUtils {
agentUser.getNickname()) ? agentUser.getNickname() : ""; agentUser.getNickname()) ? agentUser.getNickname() : "";
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentserviceid())) { if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
AgentService agentService = getAgentServiceRes().findOne( Optional<AgentService> optional = getAgentServiceRes().findById(agentUser.getAgentserviceid());
agentUser.getAgentserviceid()); if (optional.isPresent()) {
if (StringUtils.isNotBlank(agentService.getUsername())) { AgentService agentService = optional.get();
userNickName = agentService.getUsername(); if (StringUtils.isNotBlank(agentService.getUsername())) {
userNickName = agentService.getUsername();
}
} }
} }
@ -121,23 +118,23 @@ public class HumanUtils {
if (StringUtils.isNotBlank(chatMessage.getUserid()) && MainContext.MessageType.MESSAGE.toString().equals( if (StringUtils.isNotBlank(chatMessage.getUserid()) && MainContext.MessageType.MESSAGE.toString().equals(
chatMessage.getType())) { chatMessage.getType())) {
MainContext.getPeerSyncIM().send(ReceiverType.VISITOR, ChannelType.toValue(outMessage.getChannel()), MainContext.getPeerSyncIM().send(ReceiverType.VISITOR, ChannelType.toValue(outMessage.getChannel()),
outMessage.getAppid(), MessageType.MESSAGE, chatMessage.getUserid(), outMessage.getAppid(), MessageType.MESSAGE, chatMessage.getUserid(),
outMessage, true); outMessage, true);
if (statusMessage != null) { if (statusMessage != null) {
MainContext.getPeerSyncIM().send(ReceiverType.VISITOR, ChannelType.toValue(outMessage.getChannel()), MainContext.getPeerSyncIM().send(ReceiverType.VISITOR, ChannelType.toValue(outMessage.getChannel()),
outMessage.getAppid(), MessageType.STATUS, chatMessage.getUserid(), outMessage.getAppid(), MessageType.STATUS, chatMessage.getUserid(),
statusMessage, true); statusMessage, true);
} }
} }
// 将消息发送给 坐席 // 将消息发送给 坐席
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentno())) { if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentno())) {
MainContext.getPeerSyncIM().send(ReceiverType.AGENT, MainContext.getPeerSyncIM().send(ReceiverType.AGENT,
ChannelType.WEBIM, ChannelType.WEBIM,
agentUser.getAppid(), agentUser.getAppid(),
MessageType.MESSAGE, MessageType.MESSAGE,
agentUser.getAgentno(), agentUser.getAgentno(),
outMessage, true); outMessage, true);
} }
} }