mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix ChatMessageRepository related class
This commit is contained in:
parent
b4088a1bd2
commit
57b376f3aa
@ -18,15 +18,18 @@ package com.chatopera.cc.controller.api;
|
||||
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.persistence.repository.ChatMessageRepository;
|
||||
import com.chatopera.cc.socketio.message.ChatMessage;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.RestResult;
|
||||
import com.chatopera.cc.util.RestResultType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -39,27 +42,29 @@ import javax.validation.Valid;
|
||||
* 获取访客对话的内容
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/chatmessage")
|
||||
public class ApiChatMessageController extends Handler{
|
||||
public class ApiChatMessageController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRes ;
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRes;
|
||||
|
||||
/**
|
||||
* 获取访客对话内容
|
||||
* @param request
|
||||
* @param serviceid AgentServiceID
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping( method = RequestMethod.GET)
|
||||
@Menu(type = "apps" , subtype = "agentuser" , access = true)
|
||||
public ResponseEntity<RestResult> list(HttpServletRequest request , @Valid String serviceid) {
|
||||
ResponseEntity<RestResult> result = null ;
|
||||
if(!StringUtils.isBlank(serviceid)) {
|
||||
result = new ResponseEntity<>(new RestResult(RestResultType.OK, chatMessageRes.findByAgentserviceidAndOrgi(serviceid, super.getUser(request).getOrgi(), PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"))), HttpStatus.OK);
|
||||
}else {
|
||||
result = new ResponseEntity<>(new RestResult(RestResultType.LACKDATA , RestResultType.LACKDATA.getMessage()), HttpStatus.OK) ;
|
||||
}
|
||||
return result ;
|
||||
/**
|
||||
* 获取访客对话内容
|
||||
*
|
||||
* @param serviceid AgentServiceID
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@Menu(type = "apps", subtype = "agentuser", access = true)
|
||||
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String serviceid) {
|
||||
ResponseEntity<RestResult> result;
|
||||
if (!StringUtils.isBlank(serviceid)) {
|
||||
PageRequest pageRequest = PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime");
|
||||
Page<ChatMessage> page = chatMessageRes.findByAgentserviceidAndOrgi(serviceid, super.getUser(request).getOrgi(), pageRequest);
|
||||
result = new ResponseEntity<>(new RestResult(RestResultType.OK, page), HttpStatus.OK);
|
||||
} else {
|
||||
result = new ResponseEntity<>(new RestResult(RestResultType.LACKDATA, RestResultType.LACKDATA.getMessage()), HttpStatus.OK);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -29,21 +29,23 @@ import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.exception.CSKefuException;
|
||||
import com.chatopera.cc.model.*;
|
||||
import com.chatopera.cc.peer.PeerSyncIM;
|
||||
import com.chatopera.cc.persistence.es.QuickReplyRepository;
|
||||
import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.proxy.*;
|
||||
import com.chatopera.cc.socketio.message.Message;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import freemarker.template.TemplateException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -53,80 +55,72 @@ import java.util.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "/apps/cca")
|
||||
@RequiredArgsConstructor
|
||||
public class AgentAuditController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(AgentAuditController.class);
|
||||
|
||||
@Autowired
|
||||
private AgentUserProxy agentUserProxy;
|
||||
@NonNull
|
||||
private final AgentUserProxy agentUserProxy;
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
@NonNull
|
||||
private final ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private ACDMessageHelper acdMessageHelper;
|
||||
@NonNull
|
||||
private final ACDMessageHelper acdMessageHelper;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRes;
|
||||
@NonNull
|
||||
private final AgentUserRepository agentUserRes;
|
||||
|
||||
@Autowired
|
||||
private OrganRepository organRes;
|
||||
@NonNull
|
||||
private final OrganRepository organRes;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRes;
|
||||
@NonNull
|
||||
private final UserRepository userRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRepository;
|
||||
@NonNull
|
||||
private final AgentUserRepository agentUserRepository;
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRepository;
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRepository;
|
||||
|
||||
@Autowired
|
||||
private AgentServiceRepository agentServiceRes;
|
||||
@NonNull
|
||||
private final AgentServiceRepository agentServiceRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserTaskRepository agentUserTaskRes;
|
||||
@NonNull
|
||||
private final AgentUserTaskRepository agentUserTaskRes;
|
||||
|
||||
@Autowired
|
||||
private ServiceSummaryRepository serviceSummaryRes;
|
||||
@NonNull
|
||||
private final ServiceSummaryRepository serviceSummaryRes;
|
||||
|
||||
@Autowired
|
||||
private UserProxy userProxy;
|
||||
@NonNull
|
||||
private final UserProxy userProxy;
|
||||
|
||||
@Autowired
|
||||
private OnlineUserRepository onlineUserRes;
|
||||
@NonNull
|
||||
private final OnlineUserRepository onlineUserRes;
|
||||
|
||||
@Autowired
|
||||
private PbxHostRepository pbxHostRes;
|
||||
@NonNull
|
||||
private final TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
@NonNull
|
||||
private final PeerSyncIM peerSyncIM;
|
||||
|
||||
@Autowired
|
||||
private PeerSyncIM peerSyncIM;
|
||||
@NonNull
|
||||
private final TagRelationRepository tagRelationRes;
|
||||
|
||||
@Autowired
|
||||
private QuickReplyRepository quickReplyRes;
|
||||
@NonNull
|
||||
private final BlackEntityProxy blackEntityProxy;
|
||||
|
||||
@Autowired
|
||||
private QuickTypeRepository quickTypeRes;
|
||||
@NonNull
|
||||
private final BrokerPublisher brokerPublisher;
|
||||
|
||||
@Autowired
|
||||
private TagRelationRepository tagRelationRes;
|
||||
@NonNull
|
||||
private final AgentServiceProxy agentServiceProxy;
|
||||
|
||||
@Autowired
|
||||
private BlackEntityProxy blackEntityProxy;
|
||||
|
||||
@Autowired
|
||||
private BrokerPublisher brokerPublisher;
|
||||
|
||||
@Autowired
|
||||
private AgentServiceProxy agentServiceProxy;
|
||||
|
||||
@Autowired
|
||||
private ACDAgentService acdAgentService;
|
||||
@NonNull
|
||||
private final ACDAgentService acdAgentService;
|
||||
|
||||
@RequestMapping(value = "/index")
|
||||
@Menu(type = "cca", subtype = "cca", access = true)
|
||||
@ -136,7 +130,7 @@ public class AgentAuditController extends Handler {
|
||||
@Valid final String skill,
|
||||
@Valid final String agentno,
|
||||
@Valid String sort
|
||||
) {
|
||||
) {
|
||||
final String orgi = super.getOrgi(request);
|
||||
final User logined = super.getUser(request);
|
||||
logger.info("[index] skill {}, agentno {}, logined {}", skill, agentno, logined.getId());
|
||||
@ -146,14 +140,18 @@ public class AgentAuditController extends Handler {
|
||||
|
||||
if (StringUtils.isNotBlank(sort)) {
|
||||
List<Sort.Order> criterias = new ArrayList<>();
|
||||
if (sort.equals("lastmessage")) {
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "status"));
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "lastmessage"));
|
||||
} else if (sort.equals("logintime")) {
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "status"));
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "createtime"));
|
||||
} else if (sort.equals("default")) {
|
||||
defaultSort = Sort.by(Sort.Direction.DESC, "status");
|
||||
switch (sort) {
|
||||
case "lastmessage":
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "status"));
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "lastmessage"));
|
||||
break;
|
||||
case "logintime":
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "status"));
|
||||
criterias.add(new Sort.Order(Sort.Direction.DESC, "createtime"));
|
||||
break;
|
||||
case "default":
|
||||
defaultSort = Sort.by(Sort.Direction.DESC, "status");
|
||||
break;
|
||||
}
|
||||
if (criterias.size() > 0) {
|
||||
defaultSort = Sort.by(criterias);
|
||||
@ -190,7 +188,7 @@ public class AgentAuditController extends Handler {
|
||||
if (agentUsers.size() > 0) {
|
||||
view.addObject("agentUserList", agentUsers);
|
||||
|
||||
/**
|
||||
/*
|
||||
* 当前对话
|
||||
*/
|
||||
final AgentUser currentAgentUser = agentUsers.get(0);
|
||||
@ -264,7 +262,7 @@ public class AgentAuditController extends Handler {
|
||||
HttpServletRequest request,
|
||||
String id,
|
||||
String channel
|
||||
) throws IOException, TemplateException {
|
||||
) throws IOException, TemplateException {
|
||||
String mainagentuser = "/apps/cca/mainagentuser";
|
||||
if (channel.equals("phone")) {
|
||||
mainagentuser = "/apps/cca/mainagentuser_callout";
|
||||
@ -297,28 +295,25 @@ public class AgentAuditController extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
view.addObject(
|
||||
"agentUserMessageList",
|
||||
this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), orgi,
|
||||
PageRequest.of(0, 20, Sort.Direction.DESC,
|
||||
"updatetime"
|
||||
)
|
||||
)
|
||||
);
|
||||
PageRequest pageRequest = PageRequest.of(0, 20, Sort.Direction.DESC, "updatetime");
|
||||
view.addObject("agentUserMessageList",
|
||||
this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), orgi, pageRequest));
|
||||
AgentService agentService = null;
|
||||
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
|
||||
agentService = this.agentServiceRes.findOne(agentUser.getAgentserviceid());
|
||||
view.addObject("curAgentService", agentService);
|
||||
if (agentService != null) {
|
||||
/**
|
||||
Optional<AgentService> optional = this.agentServiceRes.findById(agentUser.getAgentserviceid());
|
||||
if (optional.isPresent()) {
|
||||
agentService = optional.get();
|
||||
/*
|
||||
* 获取关联数据
|
||||
*/
|
||||
agentServiceProxy.processRelaData(logined.getId(), orgi, agentService, map);
|
||||
}
|
||||
view.addObject("curAgentService", agentService);
|
||||
}
|
||||
if (MainContext.ChannelType.WEBIM.toString().equals(agentUser.getChannel())) {
|
||||
OnlineUser onlineUser = onlineUserRes.findOne(agentUser.getUserid());
|
||||
if (onlineUser != null) {
|
||||
Optional<OnlineUser> optional = onlineUserRes.findById(agentUser.getUserid());
|
||||
if (optional.isPresent()) {
|
||||
OnlineUser onlineUser = optional.get();
|
||||
if (onlineUser.getLogintime() != null) {
|
||||
if (MainContext.OnlineUserStatusEnum.OFFLINE.toString().equals(onlineUser.getStatus())) {
|
||||
onlineUser.setBetweentime(
|
||||
@ -331,12 +326,8 @@ public class AgentAuditController extends Handler {
|
||||
view.addObject("onlineUser", onlineUser);
|
||||
}
|
||||
}
|
||||
view.addObject("serviceCount", Integer
|
||||
.valueOf(this.agentServiceRes
|
||||
.countByUseridAndOrgiAndStatus(agentUser
|
||||
.getUserid(), orgi,
|
||||
MainContext.AgentUserStatusEnum.END
|
||||
.toString())));
|
||||
view.addObject("serviceCount", this.agentServiceRes
|
||||
.countByUseridAndOrgiAndStatus(agentUser.getUserid(), orgi, MainContext.AgentUserStatusEnum.END.toString()));
|
||||
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
|
||||
}
|
||||
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
||||
@ -353,13 +344,6 @@ public class AgentAuditController extends Handler {
|
||||
|
||||
/**
|
||||
* 坐席转接窗口
|
||||
*
|
||||
* @param map
|
||||
* @param request
|
||||
* @param userid
|
||||
* @param agentserviceid
|
||||
* @param agentuserid
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/transfer")
|
||||
@Menu(type = "apps", subtype = "transfer")
|
||||
@ -370,17 +354,16 @@ public class AgentAuditController extends Handler {
|
||||
final @Valid String agentserviceid,
|
||||
final @Valid String agentnoid,
|
||||
final @Valid String agentuserid
|
||||
) {
|
||||
) {
|
||||
logger.info("[transfer] userId {}, agentUser {}", userid, agentuserid);
|
||||
final String orgi = super.getOrgi(request);
|
||||
final User logined = super.getUser(request);
|
||||
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
|
||||
// 列出所有技能组
|
||||
final List<Organ> skillGroups = OnlineUserProxy.organ(orgi, true);
|
||||
|
||||
// 选择当前用户的默认技能组
|
||||
Set<String> organs = super.getUser(request).getOrgans().keySet();
|
||||
String currentOrgan = organs.size() > 0 ? (new ArrayList<String>(organs)).get(0) : null;
|
||||
String currentOrgan = organs.size() > 0 ? (new ArrayList<>(organs)).get(0) : null;
|
||||
|
||||
if (StringUtils.isBlank(currentOrgan)) {
|
||||
if (!skillGroups.isEmpty()) {
|
||||
@ -399,7 +382,7 @@ public class AgentAuditController extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
final List<User> userList = userRes.findAll(userids);
|
||||
final List<User> userList = userRes.findAllById(userids);
|
||||
for (final User o : userList) {
|
||||
o.setAgentStatus(agentStatusMap.get(o.getId()));
|
||||
// find user's skills
|
||||
@ -422,11 +405,6 @@ public class AgentAuditController extends Handler {
|
||||
|
||||
/**
|
||||
* 查找一个组织机构中的在线坐席
|
||||
*
|
||||
* @param map
|
||||
* @param request
|
||||
* @param organ
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/transfer/agent")
|
||||
@Menu(type = "apps", subtype = "transferagent")
|
||||
@ -435,10 +413,10 @@ public class AgentAuditController extends Handler {
|
||||
HttpServletRequest request,
|
||||
@Valid String agentnoid,
|
||||
@Valid String organ
|
||||
) {
|
||||
) {
|
||||
final String orgi = super.getOrgi(request);
|
||||
if (StringUtils.isNotBlank(organ)) {
|
||||
List<String> usersids = new ArrayList<String>();
|
||||
List<String> usersids = new ArrayList<>();
|
||||
final List<AgentStatus> agentStatusList = cache.getAgentStatusBySkillAndOrgi(organ, orgi);
|
||||
if (agentStatusList.size() > 0) {
|
||||
for (AgentStatus agentStatus : agentStatusList) {
|
||||
@ -447,7 +425,7 @@ public class AgentAuditController extends Handler {
|
||||
}
|
||||
}
|
||||
}
|
||||
List<User> userList = userRes.findAll(usersids);
|
||||
List<User> userList = userRes.findAllById(usersids);
|
||||
for (User user : userList) {
|
||||
userProxy.attachOrgansPropertiesForUser(user);
|
||||
for (final AgentStatus as : agentStatusList) {
|
||||
@ -466,37 +444,31 @@ public class AgentAuditController extends Handler {
|
||||
|
||||
/**
|
||||
* 执行坐席转接
|
||||
*
|
||||
* @param map
|
||||
* @param request
|
||||
* @param userid
|
||||
* @param agentserviceid
|
||||
* @param agentuserid
|
||||
* @param agentno
|
||||
* @param memo
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/transfer/save")
|
||||
@Menu(type = "apps", subtype = "transfersave")
|
||||
public ModelAndView transfersave(
|
||||
final ModelMap map, HttpServletRequest request,
|
||||
HttpServletRequest request,
|
||||
@Valid final String userid, // 访客ID
|
||||
@Valid final String agentserviceid, // 服务记录ID
|
||||
@Valid final String agentuserid, // 坐席访客ID
|
||||
@Valid final String currentAgentnoid,
|
||||
@Valid final String agentno, // 会话转接给下一个坐席
|
||||
@Valid final String memo
|
||||
) throws CSKefuException {
|
||||
final String currentAgentno = currentAgentnoid; // 当前会话坐席的agentno
|
||||
) throws CSKefuException {
|
||||
|
||||
final String orgi = super.getOrgi(request);
|
||||
|
||||
if (StringUtils.isNotBlank(userid) &&
|
||||
StringUtils.isNotBlank(agentuserid) &&
|
||||
StringUtils.isNotBlank(agentno)) {
|
||||
final User targetAgent = userRes.findOne(agentno);
|
||||
final User targetAgent = userRes.findById(agentno)
|
||||
.orElseThrow(() -> {
|
||||
String reason = String.format("Agent %s not found", agentno);
|
||||
return new ResponseStatusException(HttpStatus.NOT_FOUND, reason);
|
||||
});
|
||||
final AgentService agentService = agentServiceRes.findByIdAndOrgi(agentserviceid, super.getOrgi(request));
|
||||
/**
|
||||
/*
|
||||
* 更新AgentUser
|
||||
*/
|
||||
final AgentUser agentUser = agentUserProxy.resolveAgentUser(userid, agentuserid, orgi);
|
||||
@ -504,21 +476,21 @@ public class AgentAuditController extends Handler {
|
||||
agentUser.setAgentname(targetAgent.getUname());
|
||||
agentUserRes.save(agentUser);
|
||||
|
||||
/**
|
||||
/*
|
||||
* 坐席状态
|
||||
*/
|
||||
// 转接目标坐席
|
||||
final AgentStatus transAgentStatus = cache.findOneAgentStatusByAgentnoAndOrig(agentno, orgi);
|
||||
|
||||
// 转接源坐席
|
||||
final AgentStatus currentAgentStatus = cache.findOneAgentStatusByAgentnoAndOrig(currentAgentno, orgi);
|
||||
final AgentStatus currentAgentStatus = cache.findOneAgentStatusByAgentnoAndOrig(currentAgentnoid, orgi);
|
||||
|
||||
if (StringUtils.equals(
|
||||
MainContext.AgentUserStatusEnum.INSERVICE.toString(), agentUser.getStatus())) { //转接 , 发送消息给 目标坐席
|
||||
|
||||
// 更新当前坐席的服务访客列表
|
||||
if (currentAgentStatus != null) {
|
||||
cache.deleteOnlineUserIdFromAgentStatusByUseridAndAgentnoAndOrgi(userid, currentAgentno, orgi);
|
||||
cache.deleteOnlineUserIdFromAgentStatusByUseridAndAgentnoAndOrgi(userid, currentAgentnoid, orgi);
|
||||
agentUserProxy.updateAgentStatus(currentAgentStatus, super.getOrgi(request));
|
||||
}
|
||||
|
||||
@ -547,7 +519,7 @@ public class AgentAuditController extends Handler {
|
||||
agentUser.getUserid(),
|
||||
outMessage,
|
||||
true
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// 通知转接消息给新坐席
|
||||
@ -557,7 +529,7 @@ public class AgentAuditController extends Handler {
|
||||
MainContext.ReceiverType.AGENT, MainContext.ChannelType.WEBIM,
|
||||
agentUser.getAppid(), MainContext.MessageType.NEW, agentService.getAgentno(),
|
||||
outMessage, true
|
||||
);
|
||||
);
|
||||
|
||||
} catch (Exception ex) {
|
||||
logger.error("[transfersave]", ex);
|
||||
@ -582,11 +554,6 @@ public class AgentAuditController extends Handler {
|
||||
/**
|
||||
* 结束对话
|
||||
* 如果当前对话属于登录用户或登录用户为超级用户,则可以结束这个对话
|
||||
*
|
||||
* @param request
|
||||
* @param id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping({"/end"})
|
||||
@Menu(type = "apps", subtype = "agent")
|
||||
@ -616,8 +583,7 @@ public class AgentAuditController extends Handler {
|
||||
|
||||
@RequestMapping({"/blacklist/add"})
|
||||
@Menu(type = "apps", subtype = "blacklist")
|
||||
public ModelAndView blacklistadd(ModelMap map, HttpServletRequest request, @Valid String agentuserid, @Valid String agentserviceid, @Valid String userid)
|
||||
throws Exception {
|
||||
public ModelAndView blacklistadd(ModelMap map, HttpServletRequest request, @Valid String agentuserid, @Valid String agentserviceid, @Valid String userid) {
|
||||
map.addAttribute("agentuserid", agentuserid);
|
||||
map.addAttribute("agentserviceid", agentserviceid);
|
||||
map.addAttribute("userid", userid);
|
||||
@ -641,7 +607,7 @@ public class AgentAuditController extends Handler {
|
||||
if (StringUtils.isBlank(userid)) {
|
||||
throw new CSKefuException("Invalid userid");
|
||||
}
|
||||
/**
|
||||
/*
|
||||
* 添加黑名单
|
||||
* 一定时间后触发函数
|
||||
*/
|
||||
|
@ -277,8 +277,9 @@
|
||||
public ModelAndView agentuserLabel(String iconid) {
|
||||
String mainagentuserconter = "/apps/agent/mainagentuserconter";
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuserconter));
|
||||
ChatMessage labelid = this.chatMessageRes.findById(iconid);
|
||||
if (labelid != null) {
|
||||
Optional<ChatMessage> optional = this.chatMessageRes.findById(iconid);
|
||||
if (optional.isPresent()) {
|
||||
ChatMessage labelid = optional.get();
|
||||
labelid.setIslabel(!labelid.isIslabel());
|
||||
chatMessageRes.save(labelid);
|
||||
}
|
||||
@ -814,7 +815,8 @@
|
||||
@RequestMapping("/message/image")
|
||||
@Menu(type = "resouce", subtype = "image", access = true)
|
||||
public ModelAndView messageimage(ModelMap map, @Valid String id) {
|
||||
ChatMessage message = chatMessageRes.findById(id);
|
||||
ChatMessage message = chatMessageRes.findById(id)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("ChatMessage %s not found", id)));
|
||||
map.addAttribute("chatMessage", message);
|
||||
map.addAttribute("agentUser", cache.findOneAgentUserByUserIdAndOrgi(message.getUserid(), message.getOrgi()));
|
||||
map.addAttribute("t", true);
|
||||
@ -839,7 +841,8 @@
|
||||
}
|
||||
// 写入临时文件
|
||||
FileCopyUtils.copy(image.getBytes(), tempFile);
|
||||
ChatMessage chatMessage = chatMessageRes.findById(id);
|
||||
ChatMessage chatMessage = chatMessageRes.findById(id)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("ChatMessage %s not found", id)));
|
||||
chatMessage.setCooperation(true);
|
||||
chatMessageRes.save(chatMessage);
|
||||
|
||||
|
@ -31,12 +31,13 @@ import com.chatopera.cc.socketio.client.NettyClients;
|
||||
import com.chatopera.cc.socketio.message.ChatMessage;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import com.chatopera.cc.util.StreamingFileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
@ -46,7 +47,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -54,60 +54,51 @@ import java.util.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/ent/im")
|
||||
@RequiredArgsConstructor
|
||||
public class EntIMController extends Handler {
|
||||
@NonNull
|
||||
private final OrganRepository organRes;
|
||||
@NonNull
|
||||
private final UserRepository userRes;
|
||||
@NonNull
|
||||
private final IMGroupRepository imGroupRes;
|
||||
@NonNull
|
||||
private final IMGroupUserRepository imGroupUserRes;
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRes;
|
||||
@NonNull
|
||||
private final RecentUserRepository recentUserRes;
|
||||
@NonNull
|
||||
private final StreamingFileRepository streamingFileRepository;
|
||||
@NonNull
|
||||
private final JpaBlobHelper jpaBlobHelper;
|
||||
@NonNull
|
||||
private final UserProxy userProxy;
|
||||
@NonNull
|
||||
private final AttachmentProxy attachmentProxy;
|
||||
@NonNull
|
||||
private final PeerSyncEntIM peerSyncEntIM;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@Autowired
|
||||
private OrganRepository organRes;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRes;
|
||||
|
||||
@Autowired
|
||||
private IMGroupRepository imGroupRes;
|
||||
|
||||
@Autowired
|
||||
private IMGroupUserRepository imGroupUserRes;
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRes;
|
||||
|
||||
@Autowired
|
||||
private RecentUserRepository recentUserRes;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRepository;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
@Autowired
|
||||
AttachmentProxy attachmentProxy;
|
||||
|
||||
@Autowired
|
||||
PeerSyncEntIM peerSyncEntIM;
|
||||
|
||||
@Autowired
|
||||
private UserProxy userProxy;
|
||||
|
||||
private Map<String, Organ> getChatOrgans(User user, String orgi) {
|
||||
Map<String, Organ> organs = new HashMap<>();
|
||||
user.getOrgans().values().stream().forEach(o -> {
|
||||
user.getOrgans().values().forEach(o -> {
|
||||
if (!StringUtils.equals(o.getParent(), "0")) {
|
||||
Organ parent = organRes.findByIdAndOrgi(o.getParent(), orgi);
|
||||
organs.put(parent.getId(), parent);
|
||||
}
|
||||
|
||||
List<Organ> brother = organRes.findByOrgiAndParent(orgi, o.getParent());
|
||||
brother.stream().forEach(b -> {
|
||||
brother.forEach(b -> {
|
||||
if (!organs.containsKey(b.getId())) {
|
||||
organs.put(b.getId(), b);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
user.getAffiliates().stream().forEach(p -> {
|
||||
user.getAffiliates().forEach(p -> {
|
||||
if (!organs.containsKey(p)) {
|
||||
Organ organ = organRes.findByIdAndOrgi(p, orgi);
|
||||
organs.put(p, organ);
|
||||
@ -118,8 +109,8 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView index(HttpServletRequest request) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/index"));
|
||||
|
||||
User logined = super.getUser(request);
|
||||
@ -143,16 +134,15 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/skin")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView skin(HttpServletRequest request, HttpServletResponse response) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/skin"));
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView skin() {
|
||||
|
||||
return view;
|
||||
return request(super.createEntIMTempletResponse("/apps/entim/skin"));
|
||||
}
|
||||
|
||||
@RequestMapping("/point")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView point(HttpServletRequest request, HttpServletResponse response) {
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView point(HttpServletRequest request) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/point"));
|
||||
view.addObject(
|
||||
"recentUserList",
|
||||
@ -162,15 +152,14 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/expand")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView expand(HttpServletRequest request, HttpServletResponse response) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/expand"));
|
||||
return view;
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView expand() {
|
||||
return request(super.createEntIMTempletResponse("/apps/entim/expand"));
|
||||
}
|
||||
|
||||
@RequestMapping("/chat")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView chat(HttpServletRequest request, HttpServletResponse response, @Valid String userid) {
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView chat(HttpServletRequest request, @Valid String userid) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/chat"));
|
||||
User entImUser = userRes.findByIdAndOrgi(userid, super.getOrgi(request));
|
||||
|
||||
@ -199,13 +188,13 @@ public class EntIMController extends Handler {
|
||||
u.setUser(new User(userid));
|
||||
return u;
|
||||
});
|
||||
/**
|
||||
/*
|
||||
* 我的最近联系人
|
||||
*/
|
||||
recentUser.setNewmsg(0);
|
||||
|
||||
recentUserRes.save(recentUser);
|
||||
/**
|
||||
/*
|
||||
* 对方的最近联系人
|
||||
*/
|
||||
recentUserRes.findByCreaterAndUserAndOrgi(userid, super.getUser(request), super.getOrgi(request)).orElseGet(() -> {
|
||||
@ -221,9 +210,9 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/chat/more")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView chatMore(
|
||||
HttpServletRequest request, HttpServletResponse response, @Valid String userid,
|
||||
HttpServletRequest request, @Valid String userid,
|
||||
@Valid Date createtime
|
||||
) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/more"));
|
||||
@ -238,8 +227,8 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView groupMore(HttpServletRequest request, HttpServletResponse response, @Valid String id) {
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView groupMore(HttpServletRequest request, @Valid String id) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/group/index"));
|
||||
IMGroup imGroup = imGroupRes.findById(id);
|
||||
view.addObject("imGroup", imGroup);
|
||||
@ -252,9 +241,9 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group/more")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView group(
|
||||
HttpServletRequest request, HttpServletResponse response, @Valid String id,
|
||||
HttpServletRequest request, @Valid String id,
|
||||
@Valid Date createtime
|
||||
) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/more"));
|
||||
@ -265,18 +254,18 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group/user")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView user(HttpServletRequest request, HttpServletResponse response, @Valid String id) {
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView user(HttpServletRequest request, @Valid String id) {
|
||||
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/group/user"));
|
||||
User logined = super.getUser(request);
|
||||
HashSet<String> affiliates = logined.getAffiliates();
|
||||
|
||||
List<User> users = userProxy.findByOrganInAndDatastatus(new ArrayList<>(affiliates), false);
|
||||
users.stream().forEach(u -> userProxy.attachOrgansPropertiesForUser(u));
|
||||
users.forEach(userProxy::attachOrgansPropertiesForUser);
|
||||
view.addObject("userList", users);
|
||||
|
||||
IMGroup imGroup = imGroupRes.findById(id);
|
||||
List<Organ> organs = organRes.findAll(affiliates);
|
||||
List<Organ> organs = organRes.findAllById(affiliates);
|
||||
|
||||
view.addObject("imGroup", imGroup);
|
||||
view.addObject("organList", organs);
|
||||
@ -286,9 +275,9 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group/seluser")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public void seluser(
|
||||
HttpServletRequest request, HttpServletResponse response, @Valid String id,
|
||||
HttpServletRequest request, @Valid String id,
|
||||
@Valid String user
|
||||
) {
|
||||
IMGroup imGroup = new IMGroup();
|
||||
@ -307,9 +296,9 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group/rmuser")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public void rmluser(
|
||||
HttpServletRequest request, HttpServletResponse response, @Valid String id,
|
||||
HttpServletRequest request, @Valid String id,
|
||||
@Valid String user
|
||||
) {
|
||||
IMGroup imGroup = new IMGroup();
|
||||
@ -323,9 +312,9 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group/tipmsg")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView tipmsg(
|
||||
HttpServletRequest request, HttpServletResponse response, @Valid String id,
|
||||
@Valid String id,
|
||||
@Valid String tipmsg
|
||||
) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/tipmsg"));
|
||||
@ -339,8 +328,8 @@ public class EntIMController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/group/save")
|
||||
@Menu(type = "im", subtype = "entim", access = false)
|
||||
public ModelAndView groupsave(HttpServletRequest request, HttpServletResponse response, @Valid IMGroup group) {
|
||||
@Menu(type = "im", subtype = "entim")
|
||||
public ModelAndView groupsave(HttpServletRequest request, @Valid IMGroup group) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/entim/group/grouplist"));
|
||||
if (!StringUtils.isBlank(group.getName())
|
||||
&& imGroupRes.countByNameAndOrgi(group.getName(), super.getOrgi(request)) == 0) {
|
||||
@ -390,18 +379,19 @@ public class EntIMController extends Handler {
|
||||
public ModelAndView upload(
|
||||
ModelMap map, HttpServletRequest request,
|
||||
@RequestParam(value = "imgFile", required = false) MultipartFile multipart, @Valid String group,
|
||||
@Valid String userid, @Valid String username, @Valid String orgi, @Valid String paste
|
||||
@Valid String userid, @Valid String orgi, @Valid String paste
|
||||
) throws IOException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload"));
|
||||
final User logined = super.getUser(request);
|
||||
|
||||
UploadStatus upload = null;
|
||||
String fileName = null;
|
||||
UploadStatus upload;
|
||||
String fileName;
|
||||
|
||||
if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0
|
||||
if (multipart != null && multipart.getOriginalFilename() != null && multipart.getOriginalFilename().lastIndexOf(".") > 0
|
||||
&& StringUtils.isNotBlank(userid)) {
|
||||
File uploadDir = new File(path, "upload");
|
||||
if (!uploadDir.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
uploadDir.mkdirs();
|
||||
}
|
||||
|
||||
@ -411,7 +401,7 @@ public class EntIMController extends Handler {
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
sf.setMime(multipart.getContentType());
|
||||
if (multipart.getContentType() != null
|
||||
&& multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
||||
&& multipart.getContentType().contains(Constants.ATTACHMENT_TYPE_IMAGE)) {
|
||||
String invalid = StreamingFileUtil.getInstance().validate(Constants.ATTACHMENT_TYPE_IMAGE, multipart.getOriginalFilename());
|
||||
if (invalid == null) {
|
||||
fileName = "upload/" + fileid + "_original";
|
||||
|
@ -31,16 +31,16 @@ import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.proxy.OnlineUserProxy;
|
||||
import com.chatopera.cc.socketio.util.RichMediaUtils;
|
||||
import com.chatopera.cc.util.*;
|
||||
import freemarker.template.TemplateException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
@ -62,111 +62,77 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/im")
|
||||
@EnableAsync
|
||||
@RequiredArgsConstructor
|
||||
public class IMController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(IMController.class);
|
||||
|
||||
@Autowired
|
||||
private ACDWorkMonitor acdWorkMonitor;
|
||||
@NonNull
|
||||
private final ACDWorkMonitor acdWorkMonitor;
|
||||
|
||||
@Autowired
|
||||
private ACDPolicyService acdPolicyService;
|
||||
|
||||
@Autowired
|
||||
private OnlineUserRepository onlineUserRes;
|
||||
|
||||
@Value("${uk.im.server.host}")
|
||||
private String host;
|
||||
@NonNull
|
||||
private final ACDPolicyService acdPolicyService;
|
||||
|
||||
@NonNull
|
||||
private final OnlineUserRepository onlineUserRes;
|
||||
@NonNull
|
||||
private final StreamingFileRepository streamingFileRepository;
|
||||
@NonNull
|
||||
private final JpaBlobHelper jpaBlobHelper;
|
||||
@NonNull
|
||||
private final ConsultInviteRepository inviteRepository;
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRes;
|
||||
@NonNull
|
||||
private final AgentServiceSatisRepository agentServiceSatisRes;
|
||||
@NonNull
|
||||
private final AgentServiceRepository agentServiceRepository;
|
||||
@NonNull
|
||||
private final InviteRecordRepository inviteRecordRes;
|
||||
@NonNull
|
||||
private final LeaveMsgRepository leaveMsgRes;
|
||||
@NonNull
|
||||
private final AgentUserRepository agentUserRepository;
|
||||
@NonNull
|
||||
private final AttachmentRepository attachementRes;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
@NonNull
|
||||
private final AgentUserContactsRepository agentUserContactsRes;
|
||||
@NonNull
|
||||
private final SNSAccountRepository snsAccountRepository;
|
||||
@NonNull
|
||||
private final SNSAccountRepository snsAccountRes;
|
||||
@NonNull
|
||||
private final UserHistoryRepository userHistoryRes;
|
||||
@NonNull
|
||||
private final ChatbotRepository chatbotRes;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
@Value("${uk.im.server.port}")
|
||||
private Integer port;
|
||||
|
||||
@Value("${cs.im.server.ssl.port}")
|
||||
private Integer sslPort;
|
||||
|
||||
@Value("${web.upload-path}")
|
||||
private String path;
|
||||
|
||||
@Value("${cskefu.settings.webim.visitor-separate}")
|
||||
private Boolean channelWebIMVisitorSeparate;
|
||||
|
||||
@Autowired
|
||||
private StreamingFileRepository streamingFileRepository;
|
||||
|
||||
@Autowired
|
||||
private JpaBlobHelper jpaBlobHelper;
|
||||
|
||||
@Autowired
|
||||
private ConsultInviteRepository inviteRepository;
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRes;
|
||||
|
||||
@Autowired
|
||||
private AgentServiceSatisRepository agentServiceSatisRes;
|
||||
|
||||
@Autowired
|
||||
private AgentServiceRepository agentServiceRepository;
|
||||
|
||||
@Autowired
|
||||
private InviteRecordRepository inviteRecordRes;
|
||||
|
||||
@Autowired
|
||||
private LeaveMsgRepository leaveMsgRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRepository;
|
||||
|
||||
@Autowired
|
||||
private AttachmentRepository attachementRes;
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserContactsRepository agentUserContactsRes;
|
||||
|
||||
@Autowired
|
||||
private SNSAccountRepository snsAccountRepository;
|
||||
|
||||
@Autowired
|
||||
private SNSAccountRepository snsAccountRes;
|
||||
|
||||
@Autowired
|
||||
private UserHistoryRepository userHistoryRes;
|
||||
|
||||
@Autowired
|
||||
private ChatbotRepository chatbotRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在客户或第三方网页内,写入聊天控件
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param id
|
||||
* @param userid
|
||||
* @param title
|
||||
* @param aiid
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/{id}")
|
||||
@Menu(type = "im", subtype = "point", access = true)
|
||||
public ModelAndView point(
|
||||
HttpServletRequest request, HttpServletResponse response,
|
||||
HttpServletRequest request,
|
||||
@PathVariable String id,
|
||||
@Valid String userid,
|
||||
@Valid String title,
|
||||
@ -178,7 +144,7 @@ public class IMController extends Handler {
|
||||
logger.info("[point] session snsid {}, session {}", id, sessionid);
|
||||
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
Boolean webimexist = false;
|
||||
boolean webimexist = false;
|
||||
view.addObject("hostname", request.getServerName());
|
||||
logger.info("[point] new website is : {}", request.getServerName());
|
||||
SNSAccount SnsAccountList = snsAccountRes.findBySnsidAndOrgi(id, super.getUser(request).getOrgi());
|
||||
@ -276,12 +242,12 @@ public class IMController extends Handler {
|
||||
userHistory.setBrowser(client.getBrowser());
|
||||
userHistory.setMobile(MobileDevice.isMobile(request.getHeader("User-Agent")) ? "1" : "0");
|
||||
|
||||
if (invite.isSkill() && invite.isConsult_skill_fixed() == false) { // 展示所有技能组
|
||||
/***
|
||||
if (invite.isSkill() && !invite.isConsult_skill_fixed()) { // 展示所有技能组
|
||||
/*
|
||||
* 查询 技能组 , 缓存?
|
||||
*/
|
||||
view.addObject("skillGroups", OnlineUserProxy.organ(MainContext.SYSTEM_ORGI, ipdata, invite, true));
|
||||
/**
|
||||
/*
|
||||
* 查询坐席 , 缓存?
|
||||
*/
|
||||
view.addObject("agentList", OnlineUserProxy.agents(MainContext.SYSTEM_ORGI, true));
|
||||
@ -307,8 +273,6 @@ public class IMController extends Handler {
|
||||
}
|
||||
|
||||
private void createContacts(
|
||||
final String userid,
|
||||
final HttpServletRequest request,
|
||||
final String gid,
|
||||
final String uid,
|
||||
final String cid,
|
||||
@ -341,9 +305,7 @@ public class IMController extends Handler {
|
||||
@RequestMapping("/chatoperainit")
|
||||
@Menu(type = "im", subtype = "chatoperainit")
|
||||
public String chatoperaInit(
|
||||
ModelMap map,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
String userid,
|
||||
String uid,
|
||||
String username,
|
||||
@ -352,13 +314,12 @@ public class IMController extends Handler {
|
||||
String sid,
|
||||
String system_name,
|
||||
Boolean whitelist_mode,
|
||||
@RequestParam String sessionid) throws IOException, TemplateException {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/point"));
|
||||
@RequestParam String sessionid) {
|
||||
final User logined = super.getUser(request);
|
||||
|
||||
request.getSession().setAttribute("Sessionuid", uid);
|
||||
|
||||
Map<String, String> sessionMessage = new HashMap<String, String>();
|
||||
Map<String, String> sessionMessage = new HashMap<>();
|
||||
sessionMessage.put("username", username);
|
||||
sessionMessage.put("cid", cid);
|
||||
sessionMessage.put("company_name", company_name);
|
||||
@ -368,25 +329,23 @@ public class IMController extends Handler {
|
||||
sessionMessage.put("uid", uid);
|
||||
cache.putSystemMapByIdAndOrgi(sessionid, MainContext.SYSTEM_ORGI, sessionMessage);
|
||||
|
||||
OnlineUser onlineUser = onlineUserRes.findOne(userid);
|
||||
String updateusername;
|
||||
if (onlineUser != null) {
|
||||
updateusername = username + "@" + company_name;
|
||||
onlineUser.setUsername(updateusername);
|
||||
onlineUser.setUpdateuser(updateusername);
|
||||
onlineUser.setUpdatetime(new Date());
|
||||
onlineUserRes.save(onlineUser);
|
||||
}
|
||||
onlineUserRes.findById(userid)
|
||||
.ifPresent(onlineUser -> {
|
||||
|
||||
String updateusername;
|
||||
updateusername = username + "@" + company_name;
|
||||
onlineUser.setUsername(updateusername);
|
||||
onlineUser.setUpdateuser(updateusername);
|
||||
onlineUser.setUpdatetime(new Date());
|
||||
onlineUserRes.save(onlineUser);
|
||||
});
|
||||
|
||||
Contacts usc = contactsRes.findOneByWluidAndWlsidAndWlcidAndDatastatus(uid, sid, cid, false);
|
||||
if (usc != null) {
|
||||
return "usc";
|
||||
} else {
|
||||
if (!whitelist_mode) {
|
||||
createContacts(userid,
|
||||
request,
|
||||
logined.getId(),
|
||||
uid, cid, sid, username, company_name, system_name);
|
||||
createContacts(logined.getId(), uid, cid, sid, username, company_name, system_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +355,7 @@ public class IMController extends Handler {
|
||||
|
||||
@RequestMapping("/{id}/userlist")
|
||||
@Menu(type = "im", subtype = "inlist", access = true)
|
||||
public void inlist(HttpServletRequest request, HttpServletResponse response, @PathVariable String id, @Valid String userid) throws IOException {
|
||||
public void inlist(HttpServletResponse response, @PathVariable String id, @Valid String userid) throws IOException {
|
||||
response.setHeader("Content-Type", "text/html;charset=utf-8");
|
||||
if (StringUtils.isNotBlank(userid)) {
|
||||
BlackEntity black = cache.findOneSystemByIdAndOrgi(userid, MainContext.SYSTEM_ORGI);
|
||||
@ -408,28 +367,17 @@ public class IMController extends Handler {
|
||||
|
||||
/**
|
||||
* 延时获取用户端浏览器的跟踪ID
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param orgi
|
||||
* @param appid
|
||||
* @param userid
|
||||
* @param sign
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/online")
|
||||
@Menu(type = "im", subtype = "online", access = true)
|
||||
public SseEmitter callable(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@Valid Contacts contacts,
|
||||
final @Valid String orgi,
|
||||
final @Valid String sessionid,
|
||||
@Valid String appid,
|
||||
final @Valid String userid,
|
||||
@Valid String sign,
|
||||
final @Valid String client,
|
||||
final @Valid String title,
|
||||
final @Valid String traceid) throws InterruptedException {
|
||||
// logger.info(
|
||||
// "[online] user {}, orgi {}, traceid {}, appid {}, session {}", userid, orgi, traceid, appid, sessionid);
|
||||
@ -443,27 +391,19 @@ public class IMController extends Handler {
|
||||
|
||||
final SseEmitter emitter = new SseEmitter(30000L);
|
||||
if (StringUtils.isNotBlank(userid)) {
|
||||
emitter.onCompletion(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
OnlineUserProxy.webIMClients.removeClient(userid, client, false); // 执行了 邀请/再次邀请后终端的
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
emitter.onCompletion(() -> {
|
||||
try {
|
||||
OnlineUserProxy.webIMClients.removeClient(userid, client, false); // 执行了 邀请/再次邀请后终端的
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
emitter.onTimeout(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (emitter != null) {
|
||||
emitter.complete();
|
||||
}
|
||||
OnlineUserProxy.webIMClients.removeClient(userid, client, true); // 正常的超时断开
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
emitter.onTimeout(() -> {
|
||||
try {
|
||||
emitter.complete();
|
||||
OnlineUserProxy.webIMClients.removeClient(userid, client, true); // 正常的超时断开
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
@ -511,34 +451,6 @@ public class IMController extends Handler {
|
||||
* <p>
|
||||
* 此处返回给访客新的页面:根据访客/坐席/机器人的情况进行判断
|
||||
* 如果此处返回的是人工服务,那么此处并不寻找服务的坐席信息,而是在返回的页面中查找
|
||||
*
|
||||
* @param map
|
||||
* @param request
|
||||
* @param response
|
||||
* @param orgi
|
||||
* @param aiid
|
||||
* @param traceid
|
||||
* @param exchange
|
||||
* @param title
|
||||
* @param url
|
||||
* @param mobile
|
||||
* @param phone
|
||||
* @param ai
|
||||
* @param client
|
||||
* @param type
|
||||
* @param appid
|
||||
* @param userid
|
||||
* @param sessionid
|
||||
* @param skill
|
||||
* @param agent
|
||||
* @param contacts
|
||||
* @param product
|
||||
* @param description
|
||||
* @param imgurl
|
||||
* @param pid
|
||||
* @param purl
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/index")
|
||||
@Menu(type = "im", subtype = "index", access = true)
|
||||
@ -554,7 +466,6 @@ public class IMController extends Handler {
|
||||
@Valid final String title,
|
||||
@Valid final String url,
|
||||
@Valid final String mobile,
|
||||
@Valid final String phone,
|
||||
@Valid final String ai,
|
||||
@Valid final String client,
|
||||
@Valid final String type,
|
||||
@ -600,6 +511,7 @@ public class IMController extends Handler {
|
||||
String nickname;
|
||||
|
||||
if (sessionMessageObj != null) {
|
||||
//noinspection rawtypes
|
||||
nickname = ((Map) sessionMessageObj).get("username") + "@" + ((Map) sessionMessageObj).get(
|
||||
"company_name");
|
||||
} else if (request.getSession().getAttribute("Sessionusername") != null) {
|
||||
@ -657,7 +569,7 @@ public class IMController extends Handler {
|
||||
|
||||
map.addAttribute("cskefuport", request.getServerPort());
|
||||
|
||||
/**
|
||||
/*
|
||||
* 先检查 invite不为空
|
||||
*/
|
||||
if (invite != null) {
|
||||
@ -692,7 +604,6 @@ public class IMController extends Handler {
|
||||
// 验证 OnlineUser 信息
|
||||
if (contacts != null && StringUtils.isNotBlank(
|
||||
contacts.getName())) { //contacts用于传递信息,并不和 联系人表发生 关联,contacts信息传递给 Socket.IO,然后赋值给 AgentUser,最终赋值给 AgentService永久存储
|
||||
consult = true;
|
||||
//存入 Cookies
|
||||
if (invite.isConsult_info_cookies()) {
|
||||
Cookie name = new Cookie(
|
||||
@ -767,7 +678,7 @@ public class IMController extends Handler {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(contacts.getName())) {
|
||||
if (contacts != null && StringUtils.isBlank(contacts.getName())) {
|
||||
consult = false;
|
||||
view = request(super.createRequestPageTempletResponse("/apps/im/collecting"));
|
||||
}
|
||||
@ -786,9 +697,11 @@ public class IMController extends Handler {
|
||||
agentUserRepository.findOneByUseridAndOrgi(userid, orgi).ifPresent(p -> {
|
||||
// 关联AgentService的联系人
|
||||
if (StringUtils.isNotBlank(p.getAgentserviceid())) {
|
||||
AgentService agentService = agentServiceRepository.findOne(
|
||||
p.getAgentserviceid());
|
||||
agentService.setContactsid(contacts1.getId());
|
||||
agentServiceRepository.findById(p.getAgentserviceid())
|
||||
.ifPresent(it -> {
|
||||
it.setContactsid(contacts1.getId());
|
||||
agentServiceRepository.save(it);
|
||||
});
|
||||
}
|
||||
|
||||
// 关联AgentUserContact的联系人
|
||||
@ -833,7 +746,7 @@ public class IMController extends Handler {
|
||||
IP ipdata = IPTools.getInstance().findGeography(MainUtils.getIpAddr(request));
|
||||
map.addAttribute("skillGroups", OnlineUserProxy.organ(invite.getOrgi(), ipdata, invite, true));
|
||||
|
||||
if (invite != null && consult) {
|
||||
if (consult) {
|
||||
if (contacts != null && StringUtils.isNotBlank(contacts.getName())) {
|
||||
nickname = contacts.getName();
|
||||
}
|
||||
@ -841,13 +754,13 @@ public class IMController extends Handler {
|
||||
map.addAttribute("username", nickname);
|
||||
boolean isChatbotAgentFirst = false;
|
||||
boolean isEnableExchangeAgentType = false;
|
||||
Chatbot bot = null;
|
||||
|
||||
// 是否使用机器人客服
|
||||
if (invite.isAi() && MainContext.hasModule(Constants.CSKEFU_MODULE_CHATBOT)) {
|
||||
// 查找机器人
|
||||
bot = chatbotRes.findOne(invite.getAiid());
|
||||
if (bot != null) {
|
||||
Optional<Chatbot> optional = chatbotRes.findById(invite.getAiid());
|
||||
if (optional.isPresent()) {
|
||||
Chatbot bot = optional.get();
|
||||
// 判断是否接受访客切换坐席类型
|
||||
isEnableExchangeAgentType = !StringUtils.equals(
|
||||
bot.getWorkmode(), Constants.CHATBOT_CHATBOT_ONLY);
|
||||
@ -865,17 +778,14 @@ public class IMController extends Handler {
|
||||
|
||||
if (isChatbotAgentFirst) {
|
||||
// 机器人坐席
|
||||
HashMap<String, String> chatbotConfig = new HashMap<String, String>();
|
||||
HashMap<String, String> chatbotConfig = new HashMap<>();
|
||||
chatbotConfig.put("botname", invite.getAiname());
|
||||
chatbotConfig.put("botid", invite.getAiid());
|
||||
chatbotConfig.put("botwelcome", invite.getAimsg());
|
||||
chatbotConfig.put("botfirst", Boolean.toString(invite.isAifirst()));
|
||||
chatbotConfig.put("isai", Boolean.toString(invite.isAi()));
|
||||
|
||||
|
||||
if (chatbotConfig != null) {
|
||||
map.addAttribute("chatbotConfig", chatbotConfig);
|
||||
}
|
||||
map.addAttribute("chatbotConfig", chatbotConfig);
|
||||
view = request(super.createRequestPageTempletResponse("/apps/im/chatbot/index"));
|
||||
if (MobileDevice.isMobile(request.getHeader("User-Agent")) || StringUtils.isNotBlank(
|
||||
mobile)) {
|
||||
@ -911,8 +821,9 @@ public class IMController extends Handler {
|
||||
userid, orgi,
|
||||
MainContext.OnlineUserInviteStatus.DEFAULT.toString(),
|
||||
threshold, PageRequest.of(0, 1, Direction.DESC, "createtime"));
|
||||
if (inviteRecords.getContent() != null && inviteRecords.getContent().size() > 0) {
|
||||
final InviteRecord record = inviteRecords.getContent().get(0);
|
||||
List<InviteRecord> content = inviteRecords.getContent();
|
||||
if (content.size() > 0) {
|
||||
final InviteRecord record = content.get(0);
|
||||
record.setUpdatetime(new Date());
|
||||
record.setTraceid(traceid);
|
||||
record.setTitle(title);
|
||||
@ -936,7 +847,6 @@ public class IMController extends Handler {
|
||||
@Menu(type = "im", subtype = "index", access = true)
|
||||
public ModelAndView text(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@PathVariable String appid,
|
||||
@Valid String traceid,
|
||||
@Valid String aiid,
|
||||
@ -956,7 +866,7 @@ public class IMController extends Handler {
|
||||
@Valid String description,
|
||||
@Valid String imgurl,
|
||||
@Valid String pid,
|
||||
@Valid String purl) throws Exception {
|
||||
@Valid String purl) {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/text"));
|
||||
CousultInvite invite = OnlineUserProxy.consult(
|
||||
appid, StringUtils.isBlank(orgi) ? MainContext.SYSTEM_ORGI : orgi);
|
||||
@ -1011,16 +921,14 @@ public class IMController extends Handler {
|
||||
view.addObject("url", url);
|
||||
}
|
||||
|
||||
if (invite != null) {
|
||||
view.addObject("inviteData", invite);
|
||||
view.addObject("orgi", invite.getOrgi());
|
||||
view.addObject("appid", appid);
|
||||
view.addObject("inviteData", invite);
|
||||
view.addObject("orgi", invite.getOrgi());
|
||||
view.addObject("appid", appid);
|
||||
|
||||
if (StringUtils.isNotBlank(aiid)) {
|
||||
view.addObject("aiid", aiid);
|
||||
} else if (StringUtils.isNotBlank(invite.getAiid())) {
|
||||
view.addObject("aiid", invite.getAiid());
|
||||
}
|
||||
if (StringUtils.isNotBlank(aiid)) {
|
||||
view.addObject("aiid", aiid);
|
||||
} else if (StringUtils.isNotBlank(invite.getAiid())) {
|
||||
view.addObject("aiid", invite.getAiid());
|
||||
}
|
||||
|
||||
return view;
|
||||
@ -1028,9 +936,9 @@ public class IMController extends Handler {
|
||||
|
||||
@RequestMapping("/leavemsg/save")
|
||||
@Menu(type = "admin", subtype = "user")
|
||||
public ModelAndView leavemsgsave(HttpServletRequest request, @Valid String appid, @Valid LeaveMsg msg) {
|
||||
public ModelAndView leavemsgsave(@Valid String appid, @Valid LeaveMsg msg) {
|
||||
if (StringUtils.isNotBlank(appid)) {
|
||||
snsAccountRepository.findBySnsid(appid).ifPresent(p -> {
|
||||
snsAccountRepository.findBySnsid(appid).ifPresent(p -> {
|
||||
CousultInvite invite = inviteRepository.findBySnsaccountidAndOrgi(appid, MainContext.SYSTEM_ORGI);
|
||||
// TODO 增加策略防止恶意刷消息
|
||||
// List<LeaveMsg> msgList = leaveMsgRes.findByOrgiAndUserid(invite.getOrgi(), msg.getUserid());
|
||||
@ -1048,7 +956,7 @@ public class IMController extends Handler {
|
||||
|
||||
@RequestMapping("/refuse")
|
||||
@Menu(type = "im", subtype = "refuse", access = true)
|
||||
public void refuse(HttpServletRequest request, HttpServletResponse response, @Valid String orgi, @Valid String appid, @Valid String userid, @Valid String sessionid, @Valid String client) throws Exception {
|
||||
public void refuse(@Valid String orgi, @Valid String userid) {
|
||||
OnlineUserProxy.refuseInvite(userid, orgi);
|
||||
final Date threshold = new Date(System.currentTimeMillis() - Constants.WEBIM_AGENT_INVITE_TIMEOUT);
|
||||
Page<InviteRecord> inviteRecords = inviteRecordRes.findByUseridAndOrgiAndResultAndCreatetimeGreaterThan(
|
||||
@ -1061,19 +969,19 @@ public class IMController extends Handler {
|
||||
1,
|
||||
Direction.DESC,
|
||||
"createtime"));
|
||||
if (inviteRecords.getContent() != null && inviteRecords.getContent().size() > 0) {
|
||||
InviteRecord record = inviteRecords.getContent().get(0);
|
||||
List<InviteRecord> content = inviteRecords.getContent();
|
||||
if (content.size() > 0) {
|
||||
InviteRecord record = content.get(0);
|
||||
record.setUpdatetime(new Date());
|
||||
record.setResponsetime((int) (System.currentTimeMillis() - record.getCreatetime().getTime()));
|
||||
record.setResult(MainContext.OnlineUserInviteStatus.REFUSE.toString());
|
||||
inviteRecordRes.save(record);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@RequestMapping("/satis")
|
||||
@Menu(type = "im", subtype = "satis", access = true)
|
||||
public void satis(HttpServletRequest request, HttpServletResponse response, @Valid AgentServiceSatis satis) throws Exception {
|
||||
public void satis(@Valid AgentServiceSatis satis) {
|
||||
if (satis != null && StringUtils.isNotBlank(satis.getId())) {
|
||||
int count = agentServiceSatisRes.countById(satis.getId());
|
||||
if (count == 1) {
|
||||
@ -1085,7 +993,6 @@ public class IMController extends Handler {
|
||||
agentServiceSatisRes.save(satis);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@RequestMapping("/image/upload")
|
||||
@ -1102,8 +1009,8 @@ public class IMController extends Handler {
|
||||
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload"));
|
||||
final User logined = super.getUser(request);
|
||||
|
||||
UploadStatus upload = null;
|
||||
String fileName = null;
|
||||
UploadStatus upload;
|
||||
String fileName;
|
||||
// String multipartLast = null;
|
||||
// if ( multipart != null && multipart.getOriginalFilename() != null ){
|
||||
// Number multipartLenght = multipart.getOriginalFilename().split("\\.").length - 1;
|
||||
@ -1117,10 +1024,12 @@ public class IMController extends Handler {
|
||||
// if( multipartLast.equals("jpeg") || multipartLast.equals("jpg") || multipartLast.equals("bmp")
|
||||
// || multipartLast.equals("png") ){
|
||||
if (multipart != null
|
||||
&& multipart.getOriginalFilename() != null
|
||||
&& multipart.getOriginalFilename().lastIndexOf(".") > 0
|
||||
&& StringUtils.isNotBlank(userid)) {
|
||||
File uploadDir = new File(path, "upload");
|
||||
if (!uploadDir.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
uploadDir.mkdirs();
|
||||
}
|
||||
|
||||
@ -1131,7 +1040,7 @@ public class IMController extends Handler {
|
||||
sf.setName(multipart.getOriginalFilename());
|
||||
sf.setMime(multipart.getContentType());
|
||||
if (multipart.getContentType() != null
|
||||
&& multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) {
|
||||
&& multipart.getContentType().contains(Constants.ATTACHMENT_TYPE_IMAGE)) {
|
||||
// 检查文件格式
|
||||
String invalid = StreamingFileUtil.getInstance().validate(
|
||||
Constants.ATTACHMENT_TYPE_IMAGE, multipart.getOriginalFilename());
|
||||
@ -1173,7 +1082,7 @@ public class IMController extends Handler {
|
||||
|
||||
// 存储到本地硬盘
|
||||
String id = processAttachmentFile(multipart,
|
||||
fileid, logined.getOrgi(), logined.getId());
|
||||
fileid, logined.getOrgi(), logined.getId());
|
||||
upload = new UploadStatus("0", "/res/file.html?id=" + id);
|
||||
String file = "/res/file.html?id=" + id;
|
||||
|
||||
@ -1221,15 +1130,14 @@ public class IMController extends Handler {
|
||||
} else {
|
||||
attachmentFile.setFiletype(file.getContentType());
|
||||
}
|
||||
String originalFilename = URLDecoder.decode(file.getOriginalFilename(), "utf-8");
|
||||
String originalFilename = URLDecoder.decode(Objects.requireNonNull(file.getOriginalFilename()), "utf-8");
|
||||
File uploadFile = new File(originalFilename);
|
||||
if (uploadFile.getName() != null && uploadFile.getName().length() > 255) {
|
||||
if (uploadFile.getName().length() > 255) {
|
||||
attachmentFile.setTitle(uploadFile.getName().substring(0, 255));
|
||||
} else {
|
||||
attachmentFile.setTitle(uploadFile.getName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf(
|
||||
"image") >= 0) {
|
||||
if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().contains("image")) {
|
||||
attachmentFile.setImage(true);
|
||||
}
|
||||
attachmentFile.setFileid(fileid);
|
||||
|
@ -22,18 +22,17 @@ import com.chatopera.cc.cache.Cache;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.model.AgentService;
|
||||
import com.chatopera.cc.model.AgentServiceSummary;
|
||||
import com.chatopera.cc.model.OnlineUser;
|
||||
import com.chatopera.cc.model.WeiXinUser;
|
||||
import com.chatopera.cc.persistence.es.ContactsRepository;
|
||||
import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.proxy.AgentUserProxy;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -45,51 +44,46 @@ import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/service")
|
||||
@RequiredArgsConstructor
|
||||
public class OnlineUserController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(OnlineUserController.class);
|
||||
|
||||
@Autowired
|
||||
private AgentServiceRepository agentServiceRes;
|
||||
@NonNull
|
||||
private final AgentServiceRepository agentServiceRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserProxy agentUserProxy;
|
||||
@NonNull
|
||||
private final OnlineUserRepository onlineUserRes;
|
||||
|
||||
@Autowired
|
||||
private OnlineUserRepository onlineUserRes;
|
||||
@NonNull
|
||||
private final UserEventRepository userEventRes;
|
||||
|
||||
@Autowired
|
||||
private UserEventRepository userEventRes;
|
||||
|
||||
@Autowired
|
||||
private ServiceSummaryRepository serviceSummaryRes;
|
||||
@NonNull
|
||||
private final ServiceSummaryRepository serviceSummaryRes;
|
||||
|
||||
|
||||
@Autowired
|
||||
private OnlineUserHisRepository onlineUserHisRes;
|
||||
@NonNull
|
||||
private final OnlineUserHisRepository onlineUserHisRes;
|
||||
|
||||
@Autowired
|
||||
private WeiXinUserRepository weiXinUserRes;
|
||||
@NonNull
|
||||
private final WeiXinUserRepository weiXinUserRes;
|
||||
|
||||
@Autowired
|
||||
private TagRepository tagRes;
|
||||
@NonNull
|
||||
private final TagRepository tagRes;
|
||||
|
||||
@Autowired
|
||||
private TagRelationRepository tagRelationRes;
|
||||
@NonNull
|
||||
private final TagRelationRepository tagRelationRes;
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRepository;
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRepository;
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserContactsRepository agentUserContactsRes;
|
||||
@NonNull
|
||||
private final AgentUserContactsRepository agentUserContactsRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Autowired
|
||||
private AgentUserRepository agentUserRes;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
|
||||
@RequestMapping("/online/index")
|
||||
@Menu(type = "service", subtype = "online", admin = true)
|
||||
@ -112,10 +106,8 @@ public class OnlineUserController extends Handler {
|
||||
|
||||
map.put("agentServiceList", agentServiceList);
|
||||
if (agentServiceList.size() > 0) {
|
||||
map.put("serviceCount", Integer
|
||||
.valueOf(this.agentServiceRes
|
||||
.countByUseridAndOrgiAndStatus(userid, orgi,
|
||||
MainContext.AgentUserStatusEnum.END.toString())));
|
||||
map.put("serviceCount", this.agentServiceRes
|
||||
.countByUseridAndOrgiAndStatus(userid, orgi, MainContext.AgentUserStatusEnum.END.toString()));
|
||||
|
||||
AgentService agentService = agentServiceList.get(0);
|
||||
if (StringUtils.isNotBlank(agentservice)) {
|
||||
@ -136,10 +128,9 @@ public class OnlineUserController extends Handler {
|
||||
|
||||
}
|
||||
|
||||
agentUserContactsRes.findOneByUseridAndOrgi(
|
||||
userid, orgi).ifPresent(p -> {
|
||||
map.put("contacts", contactsRes.findOne(p.getContactsid()));
|
||||
});
|
||||
agentUserContactsRes.findOneByUseridAndOrgi(userid, orgi)
|
||||
.flatMap(p -> contactsRes.findById(p.getContactsid()))
|
||||
.ifPresent(it -> map.put("contacts", it));
|
||||
|
||||
map.put(
|
||||
"tags",
|
||||
@ -149,13 +140,11 @@ public class OnlineUserController extends Handler {
|
||||
tagRes.findByOrgiAndTagtype(orgi, MainContext.ModelType.SUMMARY.toString()));
|
||||
map.put("curAgentService", agentService);
|
||||
|
||||
|
||||
map.put(
|
||||
"agentUserMessageList",
|
||||
chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId(), orgi,
|
||||
PageRequest.of(
|
||||
0, 50, Direction.DESC,
|
||||
"updatetime")));
|
||||
if (agentService != null) {
|
||||
map.put("agentUserMessageList",
|
||||
chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId(), orgi,
|
||||
PageRequest.of(0, 50, Direction.DESC, "updatetime")));
|
||||
}
|
||||
}
|
||||
|
||||
if (MainContext.ChannelType.WEIXIN.toString().equals(channel)) {
|
||||
@ -165,17 +154,11 @@ public class OnlineUserController extends Handler {
|
||||
map.put("weiXinUser", weiXinUser);
|
||||
}
|
||||
} else if (MainContext.ChannelType.WEBIM.toString().equals(channel)) {
|
||||
OnlineUser onlineUser = onlineUserRes.findOne(userid);
|
||||
if (onlineUser != null) {
|
||||
map.put("onlineUser", onlineUser);
|
||||
}
|
||||
onlineUserRes.findById(userid)
|
||||
.ifPresent(it -> map.put("onlineUser", it));
|
||||
}
|
||||
|
||||
cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(agentUser -> {
|
||||
map.put("agentUser", agentUser);
|
||||
});
|
||||
|
||||
|
||||
cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(agentUser -> map.put("agentUser", agentUser));
|
||||
}
|
||||
return request(super.createAppsTempletResponse("/apps/service/online/index"));
|
||||
}
|
||||
@ -185,9 +168,8 @@ public class OnlineUserController extends Handler {
|
||||
public ModelAndView onlinechat(ModelMap map, HttpServletRequest request, String id, String title) {
|
||||
AgentService agentService = agentServiceRes.getOne(id);
|
||||
map.put("curAgentService", agentService);
|
||||
cache.findOneAgentUserByUserIdAndOrgi(agentService.getUserid(), super.getOrgi(request)).ifPresent(p -> {
|
||||
map.put("curragentuser", p);
|
||||
});
|
||||
cache.findOneAgentUserByUserIdAndOrgi(agentService.getUserid(), super.getOrgi(request))
|
||||
.ifPresent(p -> map.put("curragentuser", p));
|
||||
|
||||
if (StringUtils.isNotBlank(title)) {
|
||||
map.put("title", title);
|
||||
@ -197,13 +179,10 @@ public class OnlineUserController extends Handler {
|
||||
"summaryTags",
|
||||
tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString()));
|
||||
|
||||
if (agentService != null) {
|
||||
List<AgentServiceSummary> summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(
|
||||
agentService.getId(), super.getOrgi(request));
|
||||
if (summaries.size() > 0) {
|
||||
map.put("summary", summaries.get(0));
|
||||
}
|
||||
|
||||
List<AgentServiceSummary> summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(
|
||||
agentService.getId(), super.getOrgi(request));
|
||||
if (summaries.size() > 0) {
|
||||
map.put("summary", summaries.get(0));
|
||||
}
|
||||
|
||||
map.put(
|
||||
@ -216,7 +195,7 @@ public class OnlineUserController extends Handler {
|
||||
}
|
||||
|
||||
@RequestMapping("/trace")
|
||||
@Menu(type = "service", subtype = "trace", admin = false)
|
||||
@Menu(type = "service", subtype = "trace")
|
||||
public ModelAndView trace(
|
||||
final ModelMap map, final HttpServletRequest request,
|
||||
final @Valid String sessionid,
|
||||
|
@ -7,23 +7,24 @@ import com.chatopera.cc.persistence.repository.ChatMessageRepository;
|
||||
import com.chatopera.cc.persistence.repository.RecentUserRepository;
|
||||
import com.chatopera.cc.socketio.client.NettyClients;
|
||||
import com.chatopera.cc.socketio.message.ChatMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PeerSyncEntIM {
|
||||
private final static Logger logger = LoggerFactory.getLogger(
|
||||
PeerSyncEntIM.class);
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRes;
|
||||
|
||||
@Autowired
|
||||
ChatMessageRepository chatMessageRes;
|
||||
|
||||
@Autowired
|
||||
RecentUserRepository recentUserRes;
|
||||
@NonNull
|
||||
private final RecentUserRepository recentUserRes;
|
||||
|
||||
public void send(
|
||||
final String user,
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.chatopera.cc.peer.im;
|
||||
|
||||
import com.chatopera.cc.basic.MainContext;
|
||||
import com.chatopera.cc.model.AgentUserTask;
|
||||
import com.chatopera.cc.peer.PeerContext;
|
||||
import com.chatopera.cc.peer.PeerUtils;
|
||||
import com.chatopera.cc.persistence.es.ChatMessageEsRepository;
|
||||
@ -10,28 +9,30 @@ import com.chatopera.cc.persistence.repository.ChatMessageRepository;
|
||||
import com.chatopera.cc.socketio.message.ChatMessage;
|
||||
import com.chatopera.compose4j.Functional;
|
||||
import com.chatopera.compose4j.Middleware;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 做发送前的准备工作
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ComposeMw1 implements Middleware<PeerContext> {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ComposeMw1.class);
|
||||
|
||||
@Autowired
|
||||
private ChatMessageRepository chatMessageRes;
|
||||
@NonNull
|
||||
private final ChatMessageRepository chatMessageRes;
|
||||
|
||||
@Autowired
|
||||
private ChatMessageEsRepository chatMessageEsRes;
|
||||
@NonNull
|
||||
private final ChatMessageEsRepository chatMessageEsRes;
|
||||
|
||||
@Autowired
|
||||
private AgentUserTaskRepository agentUserTaskRes;
|
||||
@NonNull
|
||||
private final AgentUserTaskRepository agentUserTaskRes;
|
||||
|
||||
@Override
|
||||
public void apply(final PeerContext ctx, final Functional next) {
|
||||
@ -63,77 +64,71 @@ public class ComposeMw1 implements Middleware<PeerContext> {
|
||||
}
|
||||
|
||||
if (ctx.isSent()) {
|
||||
/**
|
||||
/*
|
||||
* 保存消息到数据库
|
||||
*/
|
||||
// 因为发送给"坐席"的消息同时包括了"发送给坐席"和"发送给访客"的内容,
|
||||
// 所以,只监控坐席的Inbound和Outbound数据就是所有的对话数据了
|
||||
switch (ctx.getReceiverType()) {
|
||||
case AGENT:
|
||||
// 只保存ChatMessage消息,不保存NEW, END 等状态
|
||||
if (ctx.getMessage().getChannelMessage() instanceof ChatMessage) {
|
||||
final ChatMessage msg = (ChatMessage) ctx.getMessage().getChannelMessage();
|
||||
// 忽略书写中的消息
|
||||
if (!PeerUtils.isMessageInWritting(msg)) {
|
||||
// 消息已经发送,保存到数据库
|
||||
chatMessageRes.save(msg);
|
||||
chatMessageEsRes.save(msg);
|
||||
logger.info("[apply] chat message saved.");
|
||||
}
|
||||
if (ctx.getReceiverType() == MainContext.ReceiverType.AGENT) {// 只保存ChatMessage消息,不保存NEW, END 等状态
|
||||
if (ctx.getMessage().getChannelMessage() instanceof ChatMessage) {
|
||||
final ChatMessage msg = (ChatMessage) ctx.getMessage().getChannelMessage();
|
||||
// 忽略书写中的消息
|
||||
if (!PeerUtils.isMessageInWritting(msg)) {
|
||||
// 消息已经发送,保存到数据库
|
||||
chatMessageRes.save(msg);
|
||||
chatMessageEsRes.save(msg);
|
||||
logger.info("[apply] chat message saved.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理坐席对话计数
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
private void prcessAgentUserTask(final PeerContext ctx) {
|
||||
AgentUserTask agentUserTask = agentUserTaskRes.getOne(ctx.getMessage().getAgentUser().getId());
|
||||
agentUserTaskRes.findById(ctx.getMessage().getAgentUser().getId())
|
||||
.ifPresent(agentUserTask -> {
|
||||
final ChatMessage received = (ChatMessage) ctx.getMessage().getChannelMessage();
|
||||
if (agentUserTask.getLastgetmessage() != null && agentUserTask.getLastmessage() != null) {
|
||||
received.setLastagentmsgtime(agentUserTask.getLastgetmessage());
|
||||
received.setLastmsgtime(agentUserTask.getLastmessage());
|
||||
received.setAgentreplyinterval(
|
||||
(int) ((System.currentTimeMillis() - agentUserTask.getLastgetmessage().getTime()) / 1000)); //坐席上次回复消息的间隔
|
||||
received.setAgentreplytime(
|
||||
(int) ((System.currentTimeMillis() - agentUserTask.getLastmessage().getTime()) / 1000)); //坐席回复消息花费时间
|
||||
}
|
||||
|
||||
if (agentUserTask != null) {
|
||||
final ChatMessage received = (ChatMessage) ctx.getMessage().getChannelMessage();
|
||||
if (agentUserTask.getLastgetmessage() != null && agentUserTask.getLastmessage() != null) {
|
||||
received.setLastagentmsgtime(agentUserTask.getLastgetmessage());
|
||||
received.setLastmsgtime(agentUserTask.getLastmessage());
|
||||
received.setAgentreplyinterval(
|
||||
(int) ((System.currentTimeMillis() - agentUserTask.getLastgetmessage().getTime()) / 1000)); //坐席上次回复消息的间隔
|
||||
received.setAgentreplytime(
|
||||
(int) ((System.currentTimeMillis() - agentUserTask.getLastmessage().getTime()) / 1000)); //坐席回复消息花费时间
|
||||
}
|
||||
agentUserTask.setAgentreplys(agentUserTask.getAgentreplys() + 1); // 总咨询记录数量
|
||||
agentUserTask.setAgentreplyinterval(
|
||||
agentUserTask.getAgentreplyinterval() + received.getAgentreplyinterval()); //总时长
|
||||
if (agentUserTask.getAgentreplys() > 0) {
|
||||
agentUserTask.setAvgreplyinterval(
|
||||
agentUserTask.getAgentreplyinterval() / agentUserTask.getAgentreplys());
|
||||
}
|
||||
|
||||
agentUserTask.setAgentreplys(agentUserTask.getAgentreplys() + 1); // 总咨询记录数量
|
||||
agentUserTask.setAgentreplyinterval(
|
||||
agentUserTask.getAgentreplyinterval() + received.getAgentreplyinterval()); //总时长
|
||||
if (agentUserTask.getAgentreplys() > 0) {
|
||||
agentUserTask.setAvgreplyinterval(
|
||||
agentUserTask.getAgentreplyinterval() / agentUserTask.getAgentreplys());
|
||||
}
|
||||
agentUserTask.setLastgetmessage(ctx.getCreatetime());
|
||||
agentUserTask.setWarnings("0");
|
||||
agentUserTask.setWarningtime(null);
|
||||
|
||||
agentUserTask.setLastgetmessage(ctx.getCreatetime());
|
||||
agentUserTask.setWarnings("0");
|
||||
agentUserTask.setWarningtime(null);
|
||||
/*
|
||||
* 去掉坐席超时回复消息提醒
|
||||
*/
|
||||
agentUserTask.setReptime(null);
|
||||
agentUserTask.setReptimes("0");
|
||||
|
||||
/**
|
||||
* 去掉坐席超时回复消息提醒
|
||||
*/
|
||||
agentUserTask.setReptime(null);
|
||||
agentUserTask.setReptimes("0");
|
||||
agentUserTask.setLastmsg(
|
||||
received.getMessage().length() > 100 ? received.getMessage().substring(
|
||||
0,
|
||||
100) : received.getMessage());
|
||||
|
||||
agentUserTask.setLastmsg(
|
||||
received.getMessage().length() > 100 ? received.getMessage().substring(
|
||||
0,
|
||||
100) : received.getMessage());
|
||||
if (StringUtils.equals(received.getType(), MainContext.MessageType.MESSAGE.toString())) {
|
||||
agentUserTask.setTokenum(agentUserTask.getTokenum() + 1);
|
||||
}
|
||||
received.setTokenum(agentUserTask.getTokenum());
|
||||
|
||||
if (StringUtils.equals(received.getType(), MainContext.MessageType.MESSAGE.toString())) {
|
||||
agentUserTask.setTokenum(agentUserTask.getTokenum() + 1);
|
||||
}
|
||||
received.setTokenum(agentUserTask.getTokenum());
|
||||
|
||||
agentUserTaskRes.save(agentUserTask);
|
||||
}
|
||||
agentUserTaskRes.save(agentUserTask);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.repository;
|
||||
|
||||
import com.chatopera.cc.socketio.message.ChatMessage;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ChatMessageRepository
|
||||
extends JpaRepository<ChatMessage, String> {
|
||||
List<ChatMessage> findByUsessionAndOrgi(String usession, String orgi);
|
||||
|
||||
ChatMessage findById(String id);
|
||||
|
||||
Page<ChatMessage> findByUsessionAndOrgi(String usession, String orgi, Pageable page);
|
||||
|
||||
// public abstract Page<ChatMessage> findByUseridAndOrgi(String usession, String orgi, Pageable page);
|
||||
//
|
||||
|
||||
@Query(value = "select u from ChatMessage u where u.usession = ?1 and u.message like %?2%")
|
||||
Page<ChatMessage> findByUsessionAndMessageLike(String usession, String message, Pageable page);
|
||||
//
|
||||
//
|
||||
// @Query(value = "select u from ChatMessage u where u.usession = ?1 and u.createtime > ?2 order by createtime")
|
||||
//
|
||||
// Page<ChatMessage> findByUsessionAndGreaterThanCreatetime(String usession,String createtime);
|
||||
//
|
||||
|
||||
@Query(value = "select * from (select * from uk_chat_message where usession = :usession and createtime <= :createtime order by createtime desc limit 0,10 )t3" +
|
||||
" UNION " +
|
||||
"select * from (select * from uk_chat_message where usession = :usession and createtime > :createtime order by createtime limit 0,9999)t4 ORDER BY createtime", nativeQuery = true)
|
||||
List<ChatMessage> findByCreatetime(@Param("usession") String usession, @Param("createtime") Date createtime);
|
||||
|
||||
@Query(value = "select u from ChatMessage u where u.usession = ?1 and u.message like %?2% and u.islabel = true")
|
||||
Page<ChatMessage> findByislabel(String usession, String message, Pageable page);
|
||||
|
||||
|
||||
@Query(value = "select * from(select * from uk_chat_message where usession = ?1 order by createtime desc limit ?2,20 ) c order by createtime asc", nativeQuery = true)
|
||||
List<ChatMessage> findByusession(String usession, Integer current);
|
||||
|
||||
// @Query(value = "select count(*) from uk_chat_message where usession = :usession and createtime <= :createtime order by createtime", nativeQuery = true)
|
||||
|
||||
int countByUsessionAndCreatetimeGreaterThanEqual(String usession, Date createtime);
|
||||
|
||||
Page<ChatMessage> findByUsessionAndCreatetimeGreaterThanEqual(String userid, String createtime, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByUseridAndOrgi(String userid, String orgi, Pageable page);
|
||||
|
||||
List<ChatMessage> findByContextidAndOrgi(String contextid, String orgi);
|
||||
|
||||
Page<ChatMessage> findByContextidAndOrgi(String contextid, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByContextidAndOrgiAndCreatetimeLessThan(String contextid, String orgi, Date createtime, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByChatypeAndOrgi(String chatype, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByAgentserviceidAndOrgi(String agentserviceid, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByContextidAndUseridAndOrgi(String contextid, String userid, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByContextidAndUseridAndOrgiAndCreatetimeLessThan(String contextid, String userid, String orgi, Date createtime, Pageable page);
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.repository;
|
||||
|
||||
import com.chatopera.cc.socketio.message.ChatMessage;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ChatMessageRepository extends JpaRepository<ChatMessage, String> {
|
||||
// List<ChatMessage> findByUsessionAndOrgi(String usession, String orgi);
|
||||
|
||||
// ChatMessage findById(String id);
|
||||
|
||||
Page<ChatMessage> findByUsessionAndOrgi(String usession, String orgi, Pageable page);
|
||||
|
||||
// public abstract Page<ChatMessage> findByUseridAndOrgi(String usession, String orgi, Pageable page);
|
||||
//
|
||||
|
||||
// @Query(value = "select u from ChatMessage u where u.usession = ?1 and u.message like %?2%")
|
||||
// Page<ChatMessage> findByUsessionAndMessageLike(String usession, String message, Pageable page);
|
||||
//
|
||||
//
|
||||
// @Query(value = "select u from ChatMessage u where u.usession = ?1 and u.createtime > ?2 order by createtime")
|
||||
//
|
||||
// Page<ChatMessage> findByUsessionAndGreaterThanCreatetime(String usession,String createtime);
|
||||
//
|
||||
|
||||
@Query(value = "select * from (select * from uk_chat_message where usession = :usession and createtime <= :createtime order by createtime desc limit 0,10 )t3" +
|
||||
" UNION " +
|
||||
"select * from (select * from uk_chat_message where usession = :usession and createtime > :createtime order by createtime limit 0,9999)t4 ORDER BY createtime", nativeQuery = true)
|
||||
List<ChatMessage> findByCreatetime(@Param("usession") String usession, @Param("createtime") Date createtime);
|
||||
|
||||
@Query(value = "select u from ChatMessage u where u.usession = ?1 and u.message like %?2% and u.islabel = true")
|
||||
Page<ChatMessage> findByislabel(String usession, String message, Pageable page);
|
||||
|
||||
|
||||
@Query(value = "select * from(select * from uk_chat_message where usession = ?1 order by createtime desc limit ?2,20 ) c order by createtime asc", nativeQuery = true)
|
||||
List<ChatMessage> findByusession(String usession, Integer current);
|
||||
|
||||
// @Query(value = "select count(*) from uk_chat_message where usession = :usession and createtime <= :createtime order by createtime", nativeQuery = true)
|
||||
|
||||
int countByUsessionAndCreatetimeGreaterThanEqual(String usession, Date createtime);
|
||||
|
||||
// Page<ChatMessage> findByUsessionAndCreatetimeGreaterThanEqual(String userid, String createtime, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByUseridAndOrgi(String userid, String orgi, Pageable page);
|
||||
|
||||
// List<ChatMessage> findByContextidAndOrgi(String contextid, String orgi);
|
||||
|
||||
Page<ChatMessage> findByContextidAndOrgi(String contextid, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByContextidAndOrgiAndCreatetimeLessThan(String contextid, String orgi, Date createtime, Pageable page);
|
||||
|
||||
// Page<ChatMessage> findByChatypeAndOrgi(String chatype, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByAgentserviceidAndOrgi(String agentserviceid, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByContextidAndUseridAndOrgi(String contextid, String userid, String orgi, Pageable page);
|
||||
|
||||
Page<ChatMessage> findByContextidAndUseridAndOrgiAndCreatetimeLessThan(String contextid, String userid, String orgi, Date createtime, Pageable page);
|
||||
}
|
||||
|
@ -26,9 +26,8 @@ import com.chatopera.cc.persistence.repository.*;
|
||||
import com.chatopera.cc.util.mobile.MobileAddress;
|
||||
import com.chatopera.cc.util.mobile.MobileNumberUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
@ -39,10 +38,10 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AgentServiceProxy {
|
||||
private final static Logger logger = LoggerFactory.getLogger(AgentServiceProxy.class);
|
||||
|
||||
@NonNull
|
||||
private final AgentServiceRepository agentServiceRes;
|
||||
@ -113,14 +112,13 @@ public class AgentServiceProxy {
|
||||
agentService.getUserid(), agentService.getOrgi()).ifPresent(p -> {
|
||||
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CONTACTS) && StringUtils.isNotBlank(
|
||||
p.getContactsid())) {
|
||||
contactsRes.findOneById(p.getContactsid()).ifPresent(k -> {
|
||||
map.addAttribute("contacts", k);
|
||||
});
|
||||
contactsRes.findOneById(p.getContactsid()).ifPresent(k -> map.addAttribute("contacts", k));
|
||||
}
|
||||
if (MainContext.hasModule(Constants.CSKEFU_MODULE_WORKORDERS) && StringUtils.isNotBlank(
|
||||
p.getContactsid())) {
|
||||
DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean(
|
||||
"workorders");
|
||||
//noinspection ConstantConditions
|
||||
if (dataExchange != null) {
|
||||
map.addAttribute(
|
||||
"workOrdersList",
|
||||
@ -135,10 +133,7 @@ public class AgentServiceProxy {
|
||||
/**
|
||||
* 增加不同渠道的信息
|
||||
*
|
||||
* @param view
|
||||
* @param agentUser
|
||||
* @param agentService
|
||||
* @param logined 登录的用户
|
||||
* @param logined 登录的用户
|
||||
*/
|
||||
public void attacheChannelInfo(
|
||||
final ModelAndView view,
|
||||
|
Loading…
x
Reference in New Issue
Block a user