diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java index a2dd4a23..844c61b1 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java @@ -1,1089 +1,1089 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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.basic; - -import com.chatopera.cc.basic.resource.ActivityResource; -import com.chatopera.cc.basic.resource.BatchResource; -import com.chatopera.cc.cache.Cache; -import com.chatopera.cc.cache.RedisCommand; -import com.chatopera.cc.peer.PeerSyncIM; -import com.chatopera.cc.util.DateConverter; -import com.chatopera.cc.util.SystemEnvHelper; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.beanutils.ConvertUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class MainContext { - - private final static Logger logger = LoggerFactory.getLogger(MainContext.class); - - private static boolean imServerRunning = false; // IM服务状态 - - public static String SYSTEM_ORGI = "cskefu"; - - private static Set modules = new HashSet(); - - public static Map> csKeFuResourceMap = new HashMap>(); - - private static ApplicationContext applicationContext; - - private static ElasticsearchTemplate templet; - - private static RedisCommand redisCommand; - - private static Cache cache; - - private static PeerSyncIM peerSyncIM; - - static { - ConvertUtils.register(new DateConverter(), java.util.Date.class); - enableModule("report"); - - csKeFuResourceMap.put(TaskType.ACTIVE.toString(), ActivityResource.class); - csKeFuResourceMap.put(TaskType.BATCH.toString(), BatchResource.class); - } - - - public enum AskSectionType { - DEFAULT; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum ActivityExecType { - DEFAULT, RECOVERY; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum AgentWorkType { - MEIDIACHAT, - CALLCENTER; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum SystemMessageType { - EMAIL, SMS; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - /** - * 名单分配状态:已分配|未分配 - * - * @author iceworld - */ - public enum NamesDisStatusType { - NOT, DISAGENT, DISORGAN, DISAI; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum QuickType { - PUB, - PRI; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum NamesProcessStatusEnum { - DIS, - PREVIEW, - CALLING, - CALLED, - CALLFAILD; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum FormFilterType { - BATCH, - BUSINESS; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum NameStatusType { - CALLED, //已拨打 - NOTCALL //未拨打 - ; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum NamesCalledEnum { - SUCCESS,//拨打成功 - FAILD, //拨打失败 - NOANSWER,//无人接听 - EMPNO, //空号 - ARREARS,//欠费 - APPO, //预约拨打 - INVALID;//无效名单 - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum TagType { - QUALITY; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum StatusType { - INBOUND, - OUTBOUND; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum LogType { - REQUEST, - CREATE, - READ, - UPDATE, - DELETE, - OTHER, - INFO, - WARN, - ERROR; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum SalesNamesStatusEnum { - DIST, //已分配 - NOTDIST; //未分配 - - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum LeaveMsgStatus { - PROCESSED, //已处理 - NOTPROCESS; //未处理 - - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum AdPosEnum { - POINT, - IMAGE, - WELCOME, - INVITE; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum QualityType { - CHAT, - VOICE; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum QualityStatusEnum { - NO, //未开启质检 - DIS, //已分配 - NODIS; //未分配 - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum CallCenterCallType { - INSIDELINE("内线", 1), - ORGCALLOUT("部门外呼", 2), - ORGCALLIN("部门呼入", 3), - INSIDEQUENE("内线排队", 4), - INSIDETRANS("内线转接", 5), //已分配 - OUTSIDELINE("外线", 6), - OUTSIDEQUENE("外线排队", 7), - OUTSIDETRANS("外线转接", 8); //未分配 - - private final String name; - private final int index; - - CallCenterCallType(final String name, final int index) { - this.name = name; - this.index = index; - } - - public String toLetters() { - return super.toString().toLowerCase(); - } - - @Override - public String toString() { - return this.name; - } - } - - // 服务处理类型 - public enum OptType { - CHATBOT("机器人客服", 1), - HUMAN("人工客服", 2); - - private final String name; - private final int index; - - OptType(String name, int index) { - this.name = name; - this.index = index; - } - - public String toLetters() { - return super.toString().toLowerCase(); - } - - @Override - public String toString() { - return this.name; - } - } - - // 外呼计划状态 - public enum CalloutDialplanStatusEnum { - RUNNING("执行中", 1), - STOPPED("已停止", 2), - STARTING("开始执行", 3), - STOPPING("停止中", 4), - INITIALIZATION("初始化", 5); - - private final String name; - private final int index; - - CalloutDialplanStatusEnum(String name, int index) { - this.name = name; - this.index = index; - } - - public String toLetters() { - return super.toString().toLowerCase(); - } - - @Override - public String toString() { - return this.name; - } - } - - public enum CallWireEventType { - DIALPLAN_CONN("自动外呼接通", 1), - DIALPLAN_DISC("自动外呼挂断", 2), - DIALPLAN_FAIL("自动外呼失败", 3), - MANUDIAL_CONN("手动外呼接通", 4), - MANUDIAL_DISC("手动外呼挂断", 5), - MANUDIAL_FAIL("手动外呼失败", 6), - CALLIN_CONN("呼入接通", 7), - CALLIN_DIST("呼入挂断", 8), - CALLIN_FAIL("呼入失败", 9); - - private String name; - private int index; - - CallWireEventType(final String name, final int index) { - this.name = name; - this.index = index; - } - - public String toLetters() { - return super.toString().toLowerCase(); - } - - public String toString() { - return this.name; - } - - public int getIndex() { - return this.index; - } - } - - - public enum CallServiceStatus { - INQUENE("就绪", 1), - RING("振铃", 2), //振铃 - INCALL("应答", 3), //应答 - BRIDGE("桥接", 4), //桥接 - HOLD("已挂起", 5), //已挂起 - HANGUP("已挂机", 6), //已挂机 - OFFLINE("离线", 7); //离线 - - private final String name; - private final int index; - - CallServiceStatus(final String name, final int index) { - this.name = name; - this.index = index; - } - - - public String toLetters() { - return super.toString().toLowerCase(); - } - - @Override - public String toString() { - return this.name; - } - } - - public enum CallChannelStatus { - EARLY, - DOWN; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum WxMpFileType { - JPG, - PNG; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum AgentInterType { - SKILL, - AGENT; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - /** - * 会话发起方 - * - * @author iceworld - */ - public enum ChatInitiatorType { - AGENT, - USER; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum ExtentionType { - LINE, - IVR, - BUSINESS, - SKILL, - CONFERENCE, - QUENE; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum DTMFType { - SATISF, - PASSWORD, //密码验证 - IDCARD, //身份证号码 - CARDNO; //银行卡号 - - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum ChatbotItemType { - USERINPUT, - BOTREPLY; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum MultiUpdateType { - SAVE, - UPDATE, - DELETE; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum ReportType { - REPORT; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum TaskType { - BATCH, - ACTIVE; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum WorkOrdersEventType { - ACCEPTUSER, //审批人变更 - OTHER; //其他变更 - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum BpmType { - WORKORDERS; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum AskOperatorType { - VIEWS, - COMMENTS, - UPS; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum ModelType { - USER, - WORKORDERS, - KBS, - SUMMARY, - CCSUMMARY, WEBIM, CALLOUT; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum AdapterType { - TEXT, - MEDIA, - AGENT, - XIAOE, - INTER; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum MetadataTableType { - UK_WORKORDERS; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum OnlineUserInviteStatus { - DEFAULT, - INVITE, - REFUSE, - INSERV, - ACCEPT; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum CustomerTypeEnum { - ENTERPRISE, - PERSONAL; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum WeiXinEventType { - SUB, - UNSUB; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - - /** - * 会话监控消息类型 - */ - public enum InterventMessageType { - @JsonProperty("text") TEXT, - @JsonProperty("status") STATUS, - @JsonProperty("image") IMAGE, - @JsonProperty("file") FILE; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - public static InterventMessageType toValue(final String str) { - for (final InterventMessageType item : values()) { - if (StringUtils.equalsIgnoreCase(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - } - - - /** - * 多渠道的渠道类型 - */ - public enum ChannelType { - WEIXIN, - WEIBO, - WEBIM, - PHONE, - SKYPE, - EMAIL, - AI; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - public static ChannelType toValue(final String str) { - for (final ChannelType item : values()) { - if (StringUtils.equalsIgnoreCase(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - } - - public enum AgentStatusEnum { - READY("就绪", 1), - NOTREADY("未就绪", 2), - BUSY("置忙", 3), - NOTBUSY("不忙", 4), - IDLE("空闲", 5), - OFFLINE("离线", 6), - SERVICES("服务", 7); - - private String name; - private int index; - - AgentStatusEnum(final String name, final int index) { - this.name = name; - this.index = index; - } - - public String zh() { - return this.name; - } - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - public static AgentStatusEnum toValue(final String str) { - for (final AgentStatusEnum item : values()) { - if (StringUtils.equalsIgnoreCase(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - - } - - public enum WorkStatusEnum { - IDLE, - WAITTING, - CALLOUT, - PREVIEW, - OUTBOUNDCALL, - SERVICES; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum TaskStatusType { - NORMAL("0"), - READ("1"), - QUEUE("5"), - RUNNING("2"), - END("3"); - - private String type; - - TaskStatusType(String type) { - this.type = type; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String toString() { - return super.toString().toLowerCase(); - } - } - - - public enum NameSpaceEnum { - - IM("/im/user"), - AGENT("/im/agent"), - ENTIM("/im/ent"), - CHATBOT("/im/chatbot"), - CALLCENTER("/callcenter/exchange"), - CALLOUT("/callout/exchange"); - - private String namespace; - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - NameSpaceEnum(String namespace) { - this.namespace = namespace; - } - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - - /** - * 接收消息的人员类型 - */ - public enum ReceiverType { - AGENT, // 坐席 - VISITOR, // 访客 - CHATBOT; // 聊天机器人 - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - public static ReceiverType toValue(final String str) { - for (final ReceiverType item : values()) { - if (StringUtils.equalsIgnoreCase(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - } - - /** - * 发送消息的内容类型 - */ - public enum MessageType { - NEW, - MESSAGE, - END, - TRANS, - TRANSOUT, // 当前会话被转接出去 - STATUS, - AGENTSTATUS, - SERVICE, - WRITING, - LEAVE, // 浏览器端执行退出 - SATISFACTION, - AUDIT_MESSAGE, // 会话监控消息类型 - AUDIT_NEW, - AUDIT_END, - AUDIT_TRANS, - AUDIT_STATUS, - AUDIT_AGENTSTATUS, - AUDIT_SERVICE, - AUDIT_WRITING; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - public static MessageType toValue(final String str) { - for (final MessageType item : values()) { - if (StringUtils.equalsIgnoreCase(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - - } - - public enum MediaType { - TEXT, - EVENT, - IMAGE, - VIDIO, - VOICE, LOCATION, FILE, COOPERATION, ACTION, PIC; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum CallType { - IN("呼入", 1), - OUT("呼出", 2), - SYSTEM("系统", 3), - INVITE("邀请", 4); - - private final String name; - private final int index; - - CallType(final String name, final int index) { - this.name = name; - this.index = index; - } - - public String toLetters() { - return super.toString().toLowerCase(); - } - - public static CallType toValue(final String str) { - for (final CallType item : values()) { - if (StringUtils.equals(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - - @Override - public String toString() { - return this.name; - } - - } - - public enum OnlineUserStatusEnum { - ONLINE, - OFFLINE, - REONLINE, - CHAT, - RECHAT, - BYE, - SEARCH, - ACCESS; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - - public static OnlineUserStatusEnum toValue(final String str) { - for (final OnlineUserStatusEnum item : values()) { - if (StringUtils.equals(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - - } - - public enum OnlineUserType { - USER, - WEBIM, - WEIXIN, - APP, - TELECOM, - SKYPE, - OTHER, - WEIBO; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - /** - * 坐席访客对话状态 - */ - public enum AgentUserStatusEnum { - INSERVICE, - INQUENE, - END; - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - - public static AgentUserStatusEnum toValue(final String str) { - for (final AgentUserStatusEnum item : values()) { - if (StringUtils.equalsIgnoreCase(item.toString(), str)) { - return item; - } - } - throw new IllegalArgumentException(); - } - } - - public static void setApplicationContext(ApplicationContext context) { - applicationContext = context; - } - - public static ApplicationContext getContext() { - return applicationContext; - } - - public static ElasticsearchTemplate getTemplet() { - return templet; - } - - public static void setTemplet(ElasticsearchTemplate templet) { - MainContext.templet = templet; - } - - /** - * 系统级的加密密码 , 从CA获取 - * - * @return - */ - public static String getSystemSecrityPassword() { - return SystemEnvHelper.parseFromApplicationProps("application.security.password"); - } - - public static void setIMServerStatus(boolean running) { - imServerRunning = running; - } - - public static boolean getIMServerStatus() { - return imServerRunning; - } - - public enum FilterCompType { - NOT, - EQUAL; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum FilterValuefilterType { - COMPARE, - RANGE; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum FilterConValueType { - INPUT, - AUTO, - USERDEF; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum FilterModelType { - TEXT, - DATE, - SIGSEL, - SELECT; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - public enum FilteFunType { - FILTER, - RANK; - - public String toString() { - return super.toString().toLowerCase(); - } - } - - /** - * 呼出电话的主叫类型 - */ - public enum CallerType { - AI, // 机器人 - AGENT; // 人工坐席 - - @Override - public String toString() { - return super.toString().toLowerCase(); - } - } - - /** - * @param resource - * @return - */ - public static Class getResource(String resource) { - return csKeFuResourceMap.get(resource); - } - - /** - * Redis底层接口 - */ - public final static RedisCommand getRedisCommand() { - if (redisCommand == null) { - redisCommand = getContext().getBean(RedisCommand.class); - } - return redisCommand; - } - - /** - * 缓存管理 - * - * @return - */ - public final static Cache getCache() { - if (cache == null) { - cache = getContext().getBean(Cache.class); - } - return cache; - } - - public final static PeerSyncIM getPeerSyncIM() { - if (peerSyncIM == null) { - peerSyncIM = getContext().getBean(PeerSyncIM.class); - } - return peerSyncIM; - } - - /** - * 开启模块 - * - * @param moduleName - */ - public static void enableModule(final String moduleName) { - logger.info("[module] enable module {}", moduleName); - modules.add(StringUtils.lowerCase(moduleName)); - } - - public static boolean hasModule(final String moduleName) { - return modules.contains(StringUtils.lowerCase(moduleName)); - } - - public static void removeModule(final String moduleName) { - modules.remove(moduleName); - } - - /** - * 获得Model - * - * @return - */ - public static Set getModules() { - return modules; - } -} +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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.basic; + +import com.chatopera.cc.basic.resource.ActivityResource; +import com.chatopera.cc.basic.resource.BatchResource; +import com.chatopera.cc.cache.Cache; +import com.chatopera.cc.cache.RedisCommand; +import com.chatopera.cc.peer.PeerSyncIM; +import com.chatopera.cc.util.DateConverter; +import com.chatopera.cc.util.SystemEnvHelper; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class MainContext { + + private final static Logger logger = LoggerFactory.getLogger(MainContext.class); + + private static boolean imServerRunning = false; // IM服务状态 + + public static String SYSTEM_ORGI = "cskefu"; + + private static final Set modules = new HashSet(); + + public static Map> csKeFuResourceMap = new HashMap>(); + + private static ApplicationContext applicationContext; + + private static ElasticsearchRestTemplate templet; + + private static RedisCommand redisCommand; + + private static Cache cache; + + private static PeerSyncIM peerSyncIM; + + static { + ConvertUtils.register(new DateConverter(), java.util.Date.class); + enableModule("report"); + + csKeFuResourceMap.put(TaskType.ACTIVE.toString(), ActivityResource.class); + csKeFuResourceMap.put(TaskType.BATCH.toString(), BatchResource.class); + } + + + public enum AskSectionType { + DEFAULT; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum ActivityExecType { + DEFAULT, RECOVERY; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum AgentWorkType { + MEIDIACHAT, + CALLCENTER; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum SystemMessageType { + EMAIL, SMS; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + /** + * 名单分配状态:已分配|未分配 + * + * @author iceworld + */ + public enum NamesDisStatusType { + NOT, DISAGENT, DISORGAN, DISAI; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum QuickType { + PUB, + PRI; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum NamesProcessStatusEnum { + DIS, + PREVIEW, + CALLING, + CALLED, + CALLFAILD; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum FormFilterType { + BATCH, + BUSINESS; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum NameStatusType { + CALLED, //已拨打 + NOTCALL //未拨打 + ; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum NamesCalledEnum { + SUCCESS,//拨打成功 + FAILD, //拨打失败 + NOANSWER,//无人接听 + EMPNO, //空号 + ARREARS,//欠费 + APPO, //预约拨打 + INVALID;//无效名单 + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum TagType { + QUALITY; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum StatusType { + INBOUND, + OUTBOUND; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum LogType { + REQUEST, + CREATE, + READ, + UPDATE, + DELETE, + OTHER, + INFO, + WARN, + ERROR; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum SalesNamesStatusEnum { + DIST, //已分配 + NOTDIST; //未分配 + + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum LeaveMsgStatus { + PROCESSED, //已处理 + NOTPROCESS; //未处理 + + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum AdPosEnum { + POINT, + IMAGE, + WELCOME, + INVITE; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum QualityType { + CHAT, + VOICE; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum QualityStatusEnum { + NO, //未开启质检 + DIS, //已分配 + NODIS; //未分配 + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum CallCenterCallType { + INSIDELINE("内线", 1), + ORGCALLOUT("部门外呼", 2), + ORGCALLIN("部门呼入", 3), + INSIDEQUENE("内线排队", 4), + INSIDETRANS("内线转接", 5), //已分配 + OUTSIDELINE("外线", 6), + OUTSIDEQUENE("外线排队", 7), + OUTSIDETRANS("外线转接", 8); //未分配 + + private final String name; + private final int index; + + CallCenterCallType(final String name, final int index) { + this.name = name; + this.index = index; + } + + public String toLetters() { + return super.toString().toLowerCase(); + } + + @Override + public String toString() { + return this.name; + } + } + + // 服务处理类型 + public enum OptType { + CHATBOT("机器人客服", 1), + HUMAN("人工客服", 2); + + private final String name; + private final int index; + + OptType(String name, int index) { + this.name = name; + this.index = index; + } + + public String toLetters() { + return super.toString().toLowerCase(); + } + + @Override + public String toString() { + return this.name; + } + } + + // 外呼计划状态 + public enum CalloutDialplanStatusEnum { + RUNNING("执行中", 1), + STOPPED("已停止", 2), + STARTING("开始执行", 3), + STOPPING("停止中", 4), + INITIALIZATION("初始化", 5); + + private final String name; + private final int index; + + CalloutDialplanStatusEnum(String name, int index) { + this.name = name; + this.index = index; + } + + public String toLetters() { + return super.toString().toLowerCase(); + } + + @Override + public String toString() { + return this.name; + } + } + + public static ElasticsearchRestTemplate getTemplet() { + return templet; + } + + + public enum CallServiceStatus { + INQUENE("就绪", 1), + RING("振铃", 2), //振铃 + INCALL("应答", 3), //应答 + BRIDGE("桥接", 4), //桥接 + HOLD("已挂起", 5), //已挂起 + HANGUP("已挂机", 6), //已挂机 + OFFLINE("离线", 7); //离线 + + private final String name; + private final int index; + + CallServiceStatus(final String name, final int index) { + this.name = name; + this.index = index; + } + + + public String toLetters() { + return super.toString().toLowerCase(); + } + + @Override + public String toString() { + return this.name; + } + } + + public enum CallChannelStatus { + EARLY, + DOWN; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum WxMpFileType { + JPG, + PNG; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum AgentInterType { + SKILL, + AGENT; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + /** + * 会话发起方 + * + * @author iceworld + */ + public enum ChatInitiatorType { + AGENT, + USER; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum ExtentionType { + LINE, + IVR, + BUSINESS, + SKILL, + CONFERENCE, + QUENE; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum DTMFType { + SATISF, + PASSWORD, //密码验证 + IDCARD, //身份证号码 + CARDNO; //银行卡号 + + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum ChatbotItemType { + USERINPUT, + BOTREPLY; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum MultiUpdateType { + SAVE, + UPDATE, + DELETE; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum ReportType { + REPORT; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum TaskType { + BATCH, + ACTIVE; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum WorkOrdersEventType { + ACCEPTUSER, //审批人变更 + OTHER; //其他变更 + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum BpmType { + WORKORDERS; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum AskOperatorType { + VIEWS, + COMMENTS, + UPS; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum ModelType { + USER, + WORKORDERS, + KBS, + SUMMARY, + CCSUMMARY, WEBIM, CALLOUT; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum AdapterType { + TEXT, + MEDIA, + AGENT, + XIAOE, + INTER; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum MetadataTableType { + UK_WORKORDERS; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum OnlineUserInviteStatus { + DEFAULT, + INVITE, + REFUSE, + INSERV, + ACCEPT; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum CustomerTypeEnum { + ENTERPRISE, + PERSONAL; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum WeiXinEventType { + SUB, + UNSUB; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + + /** + * 会话监控消息类型 + */ + public enum InterventMessageType { + @JsonProperty("text") TEXT, + @JsonProperty("status") STATUS, + @JsonProperty("image") IMAGE, + @JsonProperty("file") FILE; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + public static InterventMessageType toValue(final String str) { + for (final InterventMessageType item : values()) { + if (StringUtils.equalsIgnoreCase(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + } + + + /** + * 多渠道的渠道类型 + */ + public enum ChannelType { + WEIXIN, + WEIBO, + WEBIM, + PHONE, + SKYPE, + EMAIL, + AI; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + public static ChannelType toValue(final String str) { + for (final ChannelType item : values()) { + if (StringUtils.equalsIgnoreCase(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + } + + public static void setTemplet(ElasticsearchRestTemplate templet) { + MainContext.templet = templet; + } + + public enum WorkStatusEnum { + IDLE, + WAITTING, + CALLOUT, + PREVIEW, + OUTBOUNDCALL, + SERVICES; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum TaskStatusType { + NORMAL("0"), + READ("1"), + QUEUE("5"), + RUNNING("2"), + END("3"); + + private String type; + + TaskStatusType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String toString() { + return super.toString().toLowerCase(); + } + } + + + public enum NameSpaceEnum { + + IM("/im/user"), + AGENT("/im/agent"), + ENTIM("/im/ent"), + CHATBOT("/im/chatbot"), + CALLCENTER("/callcenter/exchange"), + CALLOUT("/callout/exchange"); + + private String namespace; + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + NameSpaceEnum(String namespace) { + this.namespace = namespace; + } + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + + /** + * 接收消息的人员类型 + */ + public enum ReceiverType { + AGENT, // 坐席 + VISITOR, // 访客 + CHATBOT; // 聊天机器人 + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + public static ReceiverType toValue(final String str) { + for (final ReceiverType item : values()) { + if (StringUtils.equalsIgnoreCase(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + } + + /** + * 发送消息的内容类型 + */ + public enum MessageType { + NEW, + MESSAGE, + END, + TRANS, + TRANSOUT, // 当前会话被转接出去 + STATUS, + AGENTSTATUS, + SERVICE, + WRITING, + LEAVE, // 浏览器端执行退出 + SATISFACTION, + AUDIT_MESSAGE, // 会话监控消息类型 + AUDIT_NEW, + AUDIT_END, + AUDIT_TRANS, + AUDIT_STATUS, + AUDIT_AGENTSTATUS, + AUDIT_SERVICE, + AUDIT_WRITING; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + public static MessageType toValue(final String str) { + for (final MessageType item : values()) { + if (StringUtils.equalsIgnoreCase(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + + } + + public enum MediaType { + TEXT, + EVENT, + IMAGE, + VIDIO, + VOICE, LOCATION, FILE, COOPERATION, ACTION, PIC; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum CallType { + IN("呼入", 1), + OUT("呼出", 2), + SYSTEM("系统", 3), + INVITE("邀请", 4); + + private final String name; + private final int index; + + CallType(final String name, final int index) { + this.name = name; + this.index = index; + } + + public String toLetters() { + return super.toString().toLowerCase(); + } + + public static CallType toValue(final String str) { + for (final CallType item : values()) { + if (StringUtils.equals(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + + @Override + public String toString() { + return this.name; + } + + } + + public enum OnlineUserStatusEnum { + ONLINE, + OFFLINE, + REONLINE, + CHAT, + RECHAT, + BYE, + SEARCH, + ACCESS; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + + public static OnlineUserStatusEnum toValue(final String str) { + for (final OnlineUserStatusEnum item : values()) { + if (StringUtils.equals(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + + } + + public enum OnlineUserType { + USER, + WEBIM, + WEIXIN, + APP, + TELECOM, + SKYPE, + OTHER, + WEIBO; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + /** + * 坐席访客对话状态 + */ + public enum AgentUserStatusEnum { + INSERVICE, + INQUENE, + END; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + public static AgentUserStatusEnum toValue(final String str) { + for (final AgentUserStatusEnum item : values()) { + if (StringUtils.equalsIgnoreCase(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + } + + public static void setApplicationContext(ApplicationContext context) { + applicationContext = context; + } + + public static ApplicationContext getContext() { + return applicationContext; + } + + public enum CallWireEventType { + DIALPLAN_CONN("自动外呼接通", 1), + DIALPLAN_DISC("自动外呼挂断", 2), + DIALPLAN_FAIL("自动外呼失败", 3), + MANUDIAL_CONN("手动外呼接通", 4), + MANUDIAL_DISC("手动外呼挂断", 5), + MANUDIAL_FAIL("手动外呼失败", 6), + CALLIN_CONN("呼入接通", 7), + CALLIN_DIST("呼入挂断", 8), + CALLIN_FAIL("呼入失败", 9); + + private final String name; + private final int index; + + CallWireEventType(final String name, final int index) { + this.name = name; + this.index = index; + } + + public String toLetters() { + return super.toString().toLowerCase(); + } + + public String toString() { + return this.name; + } + + public int getIndex() { + return this.index; + } + } + + public enum AgentStatusEnum { + READY("就绪", 1), + NOTREADY("未就绪", 2), + BUSY("置忙", 3), + NOTBUSY("不忙", 4), + IDLE("空闲", 5), + OFFLINE("离线", 6), + SERVICES("服务", 7); + + private final String name; + private final int index; + + AgentStatusEnum(final String name, final int index) { + this.name = name; + this.index = index; + } + + public String zh() { + return this.name; + } + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + public static AgentStatusEnum toValue(final String str) { + for (final AgentStatusEnum item : values()) { + if (StringUtils.equalsIgnoreCase(item.toString(), str)) { + return item; + } + } + throw new IllegalArgumentException(); + } + + } + + /** + * 系统级的加密密码 , 从CA获取 + * + * @return + */ + public static String getSystemSecrityPassword() { + return SystemEnvHelper.parseFromApplicationProps("application.security.password"); + } + + public static void setIMServerStatus(boolean running) { + imServerRunning = running; + } + + public static boolean getIMServerStatus() { + return imServerRunning; + } + + public enum FilterCompType { + NOT, + EQUAL; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum FilterValuefilterType { + COMPARE, + RANGE; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum FilterConValueType { + INPUT, + AUTO, + USERDEF; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum FilterModelType { + TEXT, + DATE, + SIGSEL, + SELECT; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + public enum FilteFunType { + FILTER, + RANK; + + public String toString() { + return super.toString().toLowerCase(); + } + } + + /** + * 呼出电话的主叫类型 + */ + public enum CallerType { + AI, // 机器人 + AGENT; // 人工坐席 + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + /** + * @param resource + * @return + */ + public static Class getResource(String resource) { + return csKeFuResourceMap.get(resource); + } + + /** + * Redis底层接口 + */ + public final static RedisCommand getRedisCommand() { + if (redisCommand == null) { + redisCommand = getContext().getBean(RedisCommand.class); + } + return redisCommand; + } + + /** + * 缓存管理 + * + * @return + */ + public final static Cache getCache() { + if (cache == null) { + cache = getContext().getBean(Cache.class); + } + return cache; + } + + public final static PeerSyncIM getPeerSyncIM() { + if (peerSyncIM == null) { + peerSyncIM = getContext().getBean(PeerSyncIM.class); + } + return peerSyncIM; + } + + /** + * 开启模块 + * + * @param moduleName + */ + public static void enableModule(final String moduleName) { + logger.info("[module] enable module {}", moduleName); + modules.add(StringUtils.lowerCase(moduleName)); + } + + public static boolean hasModule(final String moduleName) { + return modules.contains(StringUtils.lowerCase(moduleName)); + } + + public static void removeModule(final String moduleName) { + modules.remove(moduleName); + } + + /** + * 获得Model + * + * @return + */ + public static Set getModules() { + return modules; + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java index 1722917a..1f67ae96 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/resource/ActivityResource.java @@ -31,6 +31,7 @@ import org.springframework.http.HttpStatus; import org.springframework.lang.NonNull; import org.springframework.web.server.ResponseStatusException; +import java.io.IOException; import java.util.Date; import java.util.List; import java.util.Map; @@ -74,7 +75,7 @@ public class ActivityResource extends Resource { } @Override - public void begin() { + public void begin() throws IOException { if (!StringUtils.isBlank(jobDetail.getFilterid())) { formFilter = formFilterRes.findByIdAndOrgi(jobDetail.getFilterid(), this.jobDetail.getOrgi()); List formFilterList = formFilterItemRes.findByOrgiAndFormfilterid(this.jobDetail.getOrgi(), jobDetail.getFilterid()); @@ -160,7 +161,7 @@ public class ActivityResource extends Resource { } @Override - public void end(boolean clear) { + public void end(boolean clear) throws IOException { if (this.atomInt.intValue() > 0) { this.batchDataProcess.end(); } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java b/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java index 182873de..e207a31d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/config/ApplicationStartupListener.java @@ -1,50 +1,52 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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.config; - -import com.chatopera.cc.basic.MainContext; -import com.chatopera.cc.model.Favorites; -import com.chatopera.cc.model.WorkOrders; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.data.elasticsearch.ElasticsearchException; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; -import org.springframework.stereotype.Component; - -@Component -public class ApplicationStartupListener implements ApplicationListener { - - @Autowired ElasticsearchTemplate elasticSearchTemplate; - - @Override - public void onApplicationEvent(ContextRefreshedEvent event) { - if (!elasticSearchTemplate.indexExists(WorkOrders.class)) { - elasticSearchTemplate.createIndex(WorkOrders.class); - } - if (!elasticSearchTemplate.indexExists(Favorites.class)) { - elasticSearchTemplate.createIndex(Favorites.class); - } - try { - elasticSearchTemplate.getMapping(WorkOrders.class); - } catch (ElasticsearchException e) { - elasticSearchTemplate.putMapping(Favorites.class); - elasticSearchTemplate.putMapping(WorkOrders.class); - } - MainContext.setTemplet(elasticSearchTemplate); - } -} \ No newline at end of file +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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.config; + +import com.chatopera.cc.basic.MainContext; +import com.chatopera.cc.model.Favorites; +import com.chatopera.cc.model.WorkOrders; +import lombok.RequiredArgsConstructor; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.data.elasticsearch.ElasticsearchException; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class ApplicationStartupListener implements ApplicationListener { + @NonNull + private final ElasticsearchRestTemplate elasticsearchRestTemplate; + + @Override + public void onApplicationEvent(@NonNull ContextRefreshedEvent event) { + if (!elasticsearchRestTemplate.indexExists(WorkOrders.class)) { + elasticsearchRestTemplate.createIndex(WorkOrders.class); + } + if (!elasticsearchRestTemplate.indexExists(Favorites.class)) { + elasticsearchRestTemplate.createIndex(Favorites.class); + } + try { + elasticsearchRestTemplate.getMapping(WorkOrders.class); + } catch (ElasticsearchException e) { + elasticsearchRestTemplate.putMapping(Favorites.class); + elasticsearchRestTemplate.putMapping(WorkOrders.class); + } + MainContext.setTemplet(elasticsearchRestTemplate); + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/SipTrunkController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/SipTrunkController.java index a6993930..828739df 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/SipTrunkController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/SipTrunkController.java @@ -42,6 +42,7 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; import java.util.List; import java.util.Optional; @@ -73,7 +74,7 @@ public class SipTrunkController extends Handler { @RequestMapping(value = "/agent") @Menu(type = "callcenter", subtype = "agent", access = true) - public ModelAndView agent(ModelMap map, HttpServletResponse response, @Valid String ani, @Valid String sip) { + public ModelAndView agent(ModelMap map, HttpServletResponse response, @Valid String ani, @Valid String sip) throws IOException { SipTrunk sipTrunk = CallCenterUtils.siptrunk(sip, sipTrunkRes); map.addAttribute("siptrunk", sipTrunk); String agent = null; diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepositoryImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepositoryImpl.java index acaaec60..86fc226c 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepositoryImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepositoryImpl.java @@ -24,10 +24,9 @@ import org.apache.commons.lang.StringUtils; import org.elasticsearch.index.query.*; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; @@ -43,13 +42,8 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery; public class ContactsRepositoryImpl implements ContactsEsCommonRepository { @NonNull private final UserRepository userRes; - - private ElasticsearchTemplate elasticsearchTemplate; - - @Autowired - public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) { - this.elasticsearchTemplate = elasticsearchTemplate; - } + @NonNull + private final ElasticsearchRestTemplate elasticsearchRestTemplate; @Override public Page findByCreaterAndSharesAndOrgi(String creater, String shares, String orgi, boolean includeDeleteData, String q, Pageable page) { @@ -160,8 +154,8 @@ public class ContactsRepositoryImpl implements ContactsEsCommonRepository { searchQueryBuilder.withPageable(page); Page entCustomerList = null; - if (elasticsearchTemplate.indexExists(Contacts.class)) { - entCustomerList = elasticsearchTemplate.queryForPage(searchQueryBuilder.build(), Contacts.class); + if (elasticsearchRestTemplate.indexExists(Contacts.class)) { + entCustomerList = elasticsearchRestTemplate.queryForPage(searchQueryBuilder.build(), Contacts.class); } if (entCustomerList != null && entCustomerList.getContent().size() > 0) { List ids = new ArrayList<>(); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/EntCustomerRepositoryImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/EntCustomerRepositoryImpl.java index 205bfb5d..1e518bf2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/EntCustomerRepositoryImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/EntCustomerRepositoryImpl.java @@ -24,10 +24,9 @@ import org.apache.commons.lang.StringUtils; import org.elasticsearch.index.query.*; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.lang.NonNull; import org.springframework.stereotype.Repository; @@ -43,21 +42,16 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery; @RequiredArgsConstructor public class EntCustomerRepositoryImpl implements EntCustomerEsCommonRepository { - private final SimpleDateFormat dateFromate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @NonNull private final UserRepository userRes; - private ElasticsearchTemplate elasticsearchTemplate; - - @Autowired - public void setElasticsearchTemplate(ElasticsearchTemplate elasticsearchTemplate) { - this.elasticsearchTemplate = elasticsearchTemplate; - } + @NonNull + private final ElasticsearchRestTemplate elasticsearchRestTemplate; @Override public Page findByCreaterAndSharesAndOrgi(String creater, String shares, String orgi, boolean includeDeleteData, String q, Pageable page) { - BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder boolQueryBuilder1 = new BoolQueryBuilder(); boolQueryBuilder1.should(termQuery("creater", creater)); @@ -125,12 +119,12 @@ public class EntCustomerRepositoryImpl implements EntCustomerEsCommonRepository } RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("createtime"); if (begin != null) { - rangeQuery.from(dateFromate.format(begin)); + rangeQuery.from(DATE_FORMAT.format(begin)); } if (end != null) { - rangeQuery.to(dateFromate.format(end)); + rangeQuery.to(DATE_FORMAT.format(end)); } else { - rangeQuery.to(dateFromate.format(new Date())); + rangeQuery.to(DATE_FORMAT.format(new Date())); } if (begin != null || end != null) { boolQueryBuilder.must(rangeQuery); @@ -148,8 +142,8 @@ public class EntCustomerRepositoryImpl implements EntCustomerEsCommonRepository searchQueryBuilder.withPageable(page); Page entCustomerList = null; - if (elasticsearchTemplate.indexExists(EntCustomer.class)) { - entCustomerList = elasticsearchTemplate.queryForPage(searchQueryBuilder.build(), EntCustomer.class); + if (elasticsearchRestTemplate.indexExists(EntCustomer.class)) { + entCustomerList = elasticsearchRestTemplate.queryForPage(searchQueryBuilder.build(), EntCustomer.class); } if (entCustomerList != null && entCustomerList.getContent().size() > 0) { List ids = new ArrayList<>(); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicCommentRepositoryImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicCommentRepositoryImpl.java index 026aea85..8a5e140a 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicCommentRepositoryImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicCommentRepositoryImpl.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.EntityMapper; import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity; import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty; @@ -46,15 +46,15 @@ public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRep @NonNull private final UKResultMapper resultMapper; @NonNull - private final ElasticsearchTemplate elasticsearchTemplate; + private final ElasticsearchRestTemplate elasticsearchRestTemplate; @NonNull private final UKAggResultExtractor ukAggResultExtractor; @NonNull private final UKAggTopResultExtractor ukAggTopResultExtractor; - public KbsTopicCommentRepositoryImpl(@NonNull UKResultMapper resultMapper, @NonNull ElasticsearchTemplate elasticsearchTemplate, @NonNull EntityMapper entityMapper, @NonNull MappingContext, ElasticsearchPersistentProperty> mappingContext) { + public KbsTopicCommentRepositoryImpl(@NonNull UKResultMapper resultMapper, @NonNull ElasticsearchRestTemplate elasticsearchRestTemplate, @NonNull EntityMapper entityMapper, @NonNull MappingContext, ElasticsearchPersistentProperty> mappingContext) { this.resultMapper = resultMapper; - this.elasticsearchTemplate = elasticsearchTemplate; + this.elasticsearchRestTemplate = elasticsearchRestTemplate; ukAggTopResultExtractor = new UKAggTopResultExtractor(entityMapper, mappingContext); ukAggResultExtractor = new UKAggResultExtractor(entityMapper, mappingContext); } @@ -63,8 +63,8 @@ public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRep public Page findByDataid(String id, int p, int ps) { Page pages = null; SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(termQuery("dataid", id)).withSort(new FieldSortBuilder("optimal").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)).build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(KbsTopicComment.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class); + if (elasticsearchRestTemplate.indexExists(KbsTopicComment.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopicComment.class); } return pages; } @@ -73,8 +73,8 @@ public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRep public List findByOptimal(String dataid) { List commentList = null; SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(termQuery("dataid", dataid)).withQuery(termQuery("optimal", true)).build(); - if (elasticsearchTemplate.indexExists(KbsTopicComment.class)) { - commentList = elasticsearchTemplate.queryForList(searchQuery, KbsTopicComment.class); + if (elasticsearchRestTemplate.indexExists(KbsTopicComment.class)) { + commentList = elasticsearchRestTemplate.queryForList(searchQuery, KbsTopicComment.class); } return commentList; } @@ -86,13 +86,13 @@ public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRep searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)); } SearchQuery searchQuery = searchQueryBuilder.build(); - if (elasticsearchTemplate.indexExists(KbsTopicComment.class)) { + if (elasticsearchRestTemplate.indexExists(KbsTopicComment.class)) { if (!StringUtils.isBlank(q)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class, resultMapper); + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopicComment.class, resultMapper); } else { ukAggTopResultExtractor.setTerm(field); ukAggTopResultExtractor.setName(aggname); - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class, ukAggTopResultExtractor); + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopicComment.class, ukAggTopResultExtractor); } } return pages; @@ -106,7 +106,7 @@ public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRep if (!StringUtils.isBlank(q)) { searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)); } - return elasticsearchTemplate.queryForPage(searchQueryBuilder.build(), KbsTopicComment.class, resultMapper); + return elasticsearchRestTemplate.queryForPage(searchQueryBuilder.build(), KbsTopicComment.class, resultMapper); } @Override @@ -117,9 +117,9 @@ public class KbsTopicCommentRepositoryImpl implements KbsTopicCommentEsCommonRep searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)); } SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(Topic.class)) { + if (elasticsearchRestTemplate.indexExists(Topic.class)) { ukAggResultExtractor.setTerm("creater"); - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopicComment.class, ukAggResultExtractor); + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopicComment.class, ukAggResultExtractor); } return pages; } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicRepositoryImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicRepositoryImpl.java index 2d6ff0d8..0ba072ca 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicRepositoryImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/KbsTopicRepositoryImpl.java @@ -25,7 +25,7 @@ import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.SearchQuery; import org.springframework.lang.NonNull; @@ -42,7 +42,7 @@ public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository { @NonNull private final UKResultMapper ukResultMapper; @NonNull - private final ElasticsearchTemplate elasticsearchTemplate; + private final ElasticsearchRestTemplate elasticsearchRestTemplate; @Override public Page getTopicByCate(String cate, String q, final int p, final int ps) { @@ -58,8 +58,8 @@ public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(KbsTopic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class, ukResultMapper); + if (elasticsearchRestTemplate.indexExists(KbsTopic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopic.class, ukResultMapper); } return pages; } @@ -79,8 +79,8 @@ public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository { searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(KbsTopic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class, ukResultMapper); + if (elasticsearchRestTemplate.indexExists(KbsTopic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopic.class, ukResultMapper); } return pages; } @@ -99,8 +99,8 @@ public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withQuery(termQuery("creater", user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(KbsTopic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class, ukResultMapper); + if (elasticsearchRestTemplate.indexExists(KbsTopic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopic.class, ukResultMapper); } return pages; } @@ -116,8 +116,8 @@ public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(KbsTopic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, KbsTopic.class); + if (elasticsearchRestTemplate.indexExists(KbsTopic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, KbsTopic.class); } return pages; } @@ -140,8 +140,8 @@ public class KbsTopicRepositoryImpl implements KbsTopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build(); - if (elasticsearchTemplate.indexExists(KbsTopic.class)) { - list = elasticsearchTemplate.queryForList(searchQuery, KbsTopic.class); + if (elasticsearchRestTemplate.indexExists(KbsTopic.class)) { + list = elasticsearchRestTemplate.queryForList(searchQuery, KbsTopic.class); } return list; } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/QuickReplyRepositoryImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/QuickReplyRepositoryImpl.java index d769338f..15abb7b2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/QuickReplyRepositoryImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/QuickReplyRepositoryImpl.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.sort.SortOrder; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.query.DeleteQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.SearchQuery; @@ -46,7 +46,7 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { private final UKResultMapper ukResultMapper; @NonNull - private final ElasticsearchTemplate elasticsearchTemplate; + private final ElasticsearchRestTemplate elasticsearchRestTemplate; @Override public Page getByOrgiAndCate(String orgi, String cate, String q, Pageable page) { @@ -62,8 +62,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(page); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class, ukResultMapper); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, QuickReply.class, ukResultMapper); } return pages; } @@ -95,8 +95,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(0, 10000)); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - pages = elasticsearchTemplate.queryForList(searchQuery, QuickReply.class); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + pages = elasticsearchRestTemplate.queryForList(searchQuery, QuickReply.class); } return pages; } @@ -114,8 +114,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class, ukResultMapper); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, QuickReply.class, ukResultMapper); } return pages; } @@ -134,8 +134,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withQuery(termQuery("creater", user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class, ukResultMapper); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, QuickReply.class, ukResultMapper); } return pages; } @@ -151,8 +151,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, QuickReply.class); } return pages; } @@ -174,8 +174,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(page); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - list = elasticsearchTemplate.queryForPage(searchQuery, QuickReply.class); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + list = elasticsearchRestTemplate.queryForPage(searchQuery, QuickReply.class); } return list; } @@ -187,7 +187,7 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { boolQueryBuilder.must(termQuery("orgi", orgi)); boolQueryBuilder.must(termQuery("cate", cate)); deleteQuery.setQuery(boolQueryBuilder); - elasticsearchTemplate.delete(deleteQuery); + elasticsearchRestTemplate.delete(deleteQuery); } @Override @@ -210,8 +210,8 @@ public class QuickReplyRepositoryImpl implements QuickReplyEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(0, 10000)); - if (elasticsearchTemplate.indexExists(QuickReply.class)) { - list = elasticsearchTemplate.queryForList(searchQuery, QuickReply.class); + if (elasticsearchRestTemplate.indexExists(QuickReply.class)) { + list = elasticsearchRestTemplate.queryForList(searchQuery, QuickReply.class); } return list; } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepositoryImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepositoryImpl.java index ecc886f5..a170afab 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepositoryImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/TopicRepositoryImpl.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.SearchQuery; import org.springframework.lang.NonNull; @@ -41,7 +41,7 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery; @RequiredArgsConstructor public class TopicRepositoryImpl implements TopicEsCommonRepository { @NonNull - private final ElasticsearchTemplate elasticsearchTemplate; + private final ElasticsearchRestTemplate elasticsearchRestTemplate; @NonNull private final XiaoEUKResultMapper resultMapper; @@ -61,8 +61,8 @@ public class TopicRepositoryImpl implements TopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(Topic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class, resultMapper); + if (elasticsearchRestTemplate.indexExists(Topic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, Topic.class, resultMapper); } return pages; } @@ -87,8 +87,8 @@ public class TopicRepositoryImpl implements TopicEsCommonRepository { searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(Topic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class, resultMapper); + if (elasticsearchRestTemplate.indexExists(Topic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, Topic.class, resultMapper); } return pages; } @@ -107,8 +107,8 @@ public class TopicRepositoryImpl implements TopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withQuery(termQuery("creater", user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(Topic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class, resultMapper); + if (elasticsearchRestTemplate.indexExists(Topic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, Topic.class, resultMapper); } return pages; } @@ -123,8 +123,8 @@ public class TopicRepositoryImpl implements TopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withFilter(QueryBuilders.boolQuery().must(beginFilter).must(endFilter)).withSort(new FieldSortBuilder("createtime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build().setPageable(PageRequest.of(p, ps)); - if (elasticsearchTemplate.indexExists(Topic.class)) { - pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class); + if (elasticsearchRestTemplate.indexExists(Topic.class)) { + pages = elasticsearchRestTemplate.queryForPage(searchQuery, Topic.class); } return pages; } @@ -147,8 +147,8 @@ public class TopicRepositoryImpl implements TopicEsCommonRepository { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(boolQueryBuilder).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)); SearchQuery searchQuery = searchQueryBuilder.build(); - if (elasticsearchTemplate.indexExists(Topic.class)) { - list = elasticsearchTemplate.queryForList(searchQuery, Topic.class); + if (elasticsearchRestTemplate.indexExists(Topic.class)) { + list = elasticsearchRestTemplate.queryForList(searchQuery, Topic.class); } return list; } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/BatchDataProcess.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/BatchDataProcess.java index 0e4d4920..52e57d3c 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/BatchDataProcess.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/BatchDataProcess.java @@ -1,69 +1,68 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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.impl; - -import com.chatopera.cc.basic.MainContext; -import com.chatopera.cc.model.MetadataTable; -import com.chatopera.cc.util.dsdata.process.JPAProcess; -import com.chatopera.cc.util.es.UKDataBean; -import org.elasticsearch.action.bulk.BulkRequestBuilder; - -import java.util.Map; - -public class BatchDataProcess implements JPAProcess{ - - private MetadataTable metadata; - private ESDataExchangeImpl esDataExchangeImpl ; - private BulkRequestBuilder builder ; - - public BatchDataProcess(MetadataTable metadata , ESDataExchangeImpl esDataExchangeImpl) { - this.metadata = metadata ; - this.esDataExchangeImpl = esDataExchangeImpl ; - builder = MainContext.getTemplet().getClient().prepareBulk() ; - } - - @SuppressWarnings("unchecked") - @Override - public void process(Object data) { - UKDataBean dataBean = new UKDataBean(); - if(data instanceof UKDataBean) { - dataBean = (UKDataBean)data; - }else { - dataBean.setTable(this.metadata); - dataBean.setValues((Map) data); - } - try { - if(builder!=null) { - builder.add(esDataExchangeImpl.saveBulk(dataBean)) ; - }else { - esDataExchangeImpl.saveIObject(dataBean); - } - if(builder.numberOfActions() % 1000 ==0) { - builder.execute().actionGet(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void end() { - if(builder!=null) { - builder.execute().actionGet(); - } - } -} +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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.impl; + +import com.chatopera.cc.basic.MainContext; +import com.chatopera.cc.model.MetadataTable; +import com.chatopera.cc.util.dsdata.process.JPAProcess; +import com.chatopera.cc.util.es.UKDataBean; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.client.RequestOptions; +import org.springframework.lang.NonNull; + +import java.io.IOException; +import java.util.Map; + +public class BatchDataProcess implements JPAProcess { + + private final MetadataTable metadata; + private final ESDataExchangeImpl esDataExchangeImpl; + @NonNull + private final BulkRequest request; + + public BatchDataProcess(MetadataTable metadata, ESDataExchangeImpl esDataExchangeImpl) { + this.metadata = metadata; + this.esDataExchangeImpl = esDataExchangeImpl; + request = new BulkRequest(); + } + + @SuppressWarnings("unchecked") + @Override + public void process(Object data) { + UKDataBean dataBean = new UKDataBean(); + if (data instanceof UKDataBean) { + dataBean = (UKDataBean) data; + } else { + dataBean.setTable(this.metadata); + dataBean.setValues((Map) data); + } + try { + request.add(esDataExchangeImpl.saveBulk(dataBean)); + if (request.numberOfActions() % 1000 == 0) { + end(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void end() throws IOException { + MainContext.getTemplet().getClient().bulk(request, RequestOptions.DEFAULT); + request.requests().clear(); + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/DataBatProcess.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/DataBatProcess.java index 4bc6431e..04334ab5 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/DataBatProcess.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/DataBatProcess.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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.impl; - -import com.chatopera.cc.basic.MainContext; -import com.chatopera.cc.util.dsdata.process.JPAProcess; -import com.chatopera.cc.util.es.UKDataBean; -import org.elasticsearch.action.bulk.BulkRequestBuilder; - -public class DataBatProcess implements JPAProcess{ - - private ESDataExchangeImpl esDataExchangeImpl ; - private BulkRequestBuilder builder ; - - public DataBatProcess(ESDataExchangeImpl esDataExchangeImpl) { - this.esDataExchangeImpl = esDataExchangeImpl ; - builder = MainContext.getTemplet().getClient().prepareBulk() ; - } - - @Override - public void process(Object data) { - if(data instanceof UKDataBean){ - UKDataBean dataBean = (UKDataBean)data; - try { - if(builder!=null) { - builder.add(esDataExchangeImpl.saveBulk(dataBean)) ; - }else { - esDataExchangeImpl.saveIObject(dataBean); - } - if(builder.numberOfActions() % 1000 ==0) { - builder.execute().actionGet(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public void end() { - if(builder!=null) { - builder.execute().actionGet(); - } - } -} +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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.impl; + +import com.chatopera.cc.basic.MainContext; +import com.chatopera.cc.util.dsdata.process.JPAProcess; +import com.chatopera.cc.util.es.UKDataBean; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.client.RequestOptions; +import org.springframework.lang.NonNull; + +import java.io.IOException; + +public class DataBatProcess implements JPAProcess { + @NonNull + private final BulkRequest request; + @NonNull + private final ESDataExchangeImpl esDataExchangeImpl; + + public DataBatProcess(@NonNull ESDataExchangeImpl esDataExchangeImpl) { + this.esDataExchangeImpl = esDataExchangeImpl; + request = new BulkRequest(); + } + + @Override + public void process(Object data) { + if (data instanceof UKDataBean) { + UKDataBean dataBean = (UKDataBean) data; + try { + request.add(esDataExchangeImpl.saveBulk(dataBean)); + if (request.numberOfActions() % 1000 == 0) { + end(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public void end() throws IOException { + MainContext.getTemplet().getClient().bulk(request, RequestOptions.DEFAULT); + request.requests().clear(); + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/ESDataExchangeImpl.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/ESDataExchangeImpl.java index b9c08919..91afc23d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/ESDataExchangeImpl.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/impl/ESDataExchangeImpl.java @@ -25,10 +25,12 @@ import com.chatopera.cc.persistence.repository.UserRepository; import com.chatopera.cc.util.es.UKDataBean; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.aggregations.Aggregation; @@ -36,6 +38,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilder; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.StringTerms; import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.springframework.data.domain.PageImpl; @@ -44,6 +47,7 @@ import org.springframework.data.domain.Sort.Order; import org.springframework.lang.NonNull; import org.springframework.stereotype.Repository; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -62,31 +66,26 @@ public class ESDataExchangeImpl { @NonNull private final OrganRepository organRes; - public void saveIObject(UKDataBean dataBean) { + public void saveIObject(UKDataBean dataBean) throws IOException { if (dataBean.getId() == null) { dataBean.setId((String) dataBean.getValues().get("id")); } - this.saveBulk(dataBean).execute().actionGet(); + MainContext.getTemplet().getClient().index(this.saveBulk(dataBean), RequestOptions.DEFAULT); } - /** - * - */ - public IndexRequestBuilder saveBulk(UKDataBean dataBean) { - IndexRequestBuilder indexRequestBuilder; + @NonNull + public IndexRequest saveBulk(UKDataBean dataBean) { if (dataBean.getId() == null) { dataBean.setId((String) dataBean.getValues().get("id")); } + String type; if (!StringUtils.isBlank(dataBean.getType())) { - indexRequestBuilder = MainContext.getTemplet().getClient().prepareIndex(Constants.SYSTEM_INDEX, - dataBean.getType(), dataBean.getId()) - .setSource(processValues(dataBean)); + type = dataBean.getType(); } else { - indexRequestBuilder = MainContext.getTemplet().getClient().prepareIndex(Constants.SYSTEM_INDEX, - dataBean.getTable().getTablename(), dataBean.getId()) - .setSource(processValues(dataBean)); + type = dataBean.getTable().getTablename(); } - return indexRequestBuilder; + return new IndexRequest(Constants.SYSTEM_INDEX, + type, dataBean.getId()).source(processValues(dataBean)); } /** @@ -113,18 +112,16 @@ public class ESDataExchangeImpl { public void deleteById(String type, String id) { if (!StringUtils.isBlank(type) && !StringUtils.isBlank(id)) { - MainContext.getTemplet().getClient() - .prepareDelete(Constants.SYSTEM_INDEX, type, id).execute().actionGet(); + MainContext.getTemplet().delete(Constants.SYSTEM_INDEX, type, id); } } - public UKDataBean getIObjectByPK(UKDataBean dataBean) { + public UKDataBean getIObjectByPK(UKDataBean dataBean) throws IOException { if (dataBean.getTable() != null) { GetResponse getResponse = MainContext.getTemplet().getClient() - .prepareGet(Constants.SYSTEM_INDEX, - dataBean.getTable().getTablename(), dataBean.getId()) - .execute().actionGet(); + .get(new GetRequest(Constants.SYSTEM_INDEX, + dataBean.getTable().getTablename(), dataBean.getId()), RequestOptions.DEFAULT); dataBean.setValues(getResponse.getSource()); dataBean.setType(getResponse.getType()); } else { @@ -134,13 +131,12 @@ public class ESDataExchangeImpl { return processDate(dataBean); } - public UKDataBean getIObjectByPK(String type, String id) { + public UKDataBean getIObjectByPK(String type, String id) throws IOException { UKDataBean dataBean = new UKDataBean(); if (!StringUtils.isBlank(type)) { GetResponse getResponse = MainContext.getTemplet().getClient() - .prepareGet(Constants.SYSTEM_INDEX, - type, id) - .execute().actionGet(); + .get(new GetRequest(Constants.SYSTEM_INDEX, + type, id), RequestOptions.DEFAULT); dataBean.setValues(getResponse.getSource()); dataBean.setType(getResponse.getType()); } else { @@ -152,32 +148,35 @@ public class ESDataExchangeImpl { /** * */ - public PageImpl findPageResult(QueryBuilder query, MetadataTable metadata, Pageable page, boolean loadRef) { + public PageImpl findPageResult(QueryBuilder query, MetadataTable metadata, Pageable page, boolean loadRef) throws IOException { return findAllPageResult(query, metadata, page, loadRef, metadata != null ? metadata.getTablename() : null); } /** * */ - public PageImpl findAllPageResult(QueryBuilder query, MetadataTable metadata, Pageable page, boolean loadRef, String types) { - List dataBeanList = new ArrayList<>(); - SearchRequestBuilder searchBuilder = MainContext.getTemplet().getClient().prepareSearch(Constants.SYSTEM_INDEX); - if (!StringUtils.isBlank(types)) { - searchBuilder.setTypes(types); + public PageImpl findAllPageResult(QueryBuilder query, MetadataTable metadata, Pageable page, boolean loadRef, String types) throws IOException { + + SearchSourceBuilder source = new SearchSourceBuilder(); + int start = page.getPageSize() * page.getPageNumber(); + source.from(start).size(page.getPageSize()).query(query); + + for (Order order : page.getSort()) { + source.sort(new FieldSortBuilder(order.getProperty()).unmappedType(order.getProperty().equals("createtime") ? "long" : "string").order(order.isDescending() ? SortOrder.DESC : SortOrder.ASC)); } - int start = page.getPageSize() * page.getPageNumber(); - searchBuilder.setFrom(start).setSize(page.getPageSize()); - page.getSort(); - for (Order order : page.getSort()) { - searchBuilder.addSort(new FieldSortBuilder(order.getProperty()).unmappedType(order.getProperty().equals("createtime") ? "long" : "string").order(order.isDescending() ? SortOrder.DESC : SortOrder.ASC)); + SearchRequest request = new SearchRequest(new String[]{Constants.SYSTEM_INDEX}, source); + if (!StringUtils.isBlank(types)) { + request.types(types); } - SearchResponse response = searchBuilder.setQuery(query).execute().actionGet(); + + SearchResponse response = MainContext.getTemplet().getClient().search(request, RequestOptions.DEFAULT); List users = new ArrayList<>(); List organs = new ArrayList<>(); List taskList = new ArrayList<>(); // List batchList = new ArrayList<>(); // List activityList = new ArrayList<>(); + List dataBeanList = new ArrayList<>(); for (SearchHit hit : response.getHits().getHits()) { UKDataBean temp = new UKDataBean(); temp.setType(hit.getType()); @@ -268,29 +267,26 @@ public class ESDataExchangeImpl { /** * */ - public PageImpl findAllPageAggResult(QueryBuilder query, String aggField, Pageable page, boolean loadRef, String types) { - List dataBeanList = new ArrayList<>(); - SearchRequestBuilder searchBuilder = MainContext.getTemplet().getClient().prepareSearch(Constants.SYSTEM_INDEX); - if (!StringUtils.isBlank(types)) { - searchBuilder.setTypes(types); - } + public PageImpl findAllPageAggResult(QueryBuilder query, String aggField, Pageable page, boolean loadRef, String types) throws IOException { int size = page.getPageSize() * (page.getPageNumber() + 1); - searchBuilder.setFrom(0).setSize(0); AggregationBuilder aggregition = AggregationBuilders.terms(aggField).field(aggField).size(size); aggregition.subAggregation(AggregationBuilders.terms("apstatus").field("apstatus")); aggregition.subAggregation(AggregationBuilders.terms("callstatus").field("callstatus")); - searchBuilder.addAggregation(aggregition); - - - SearchResponse response = searchBuilder.setQuery(query).execute().actionGet(); + SearchSourceBuilder source = new SearchSourceBuilder().aggregation(aggregition).query(query); + SearchRequest request = new SearchRequest(new String[]{Constants.SYSTEM_INDEX}, source); + if (!StringUtils.isBlank(types)) { + request.types(types); + } + SearchResponse response = MainContext.getTemplet().getClient().search(request, RequestOptions.DEFAULT); List users = new ArrayList<>(); List organs = new ArrayList<>(); List taskList = new ArrayList<>(); // List batchList = new ArrayList<>(); // List activityList = new ArrayList<>(); + List dataBeanList = new ArrayList<>(); if (response.getAggregations().get(aggField) instanceof Terms) { Terms agg = response.getAggregations().get(aggField); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/CallCenterUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/util/CallCenterUtils.java index dc2f7b4f..904690db 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/CallCenterUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/CallCenterUtils.java @@ -32,6 +32,7 @@ import org.springframework.ui.ModelMap; import javax.persistence.criteria.CriteriaBuilder.In; import javax.persistence.criteria.Predicate; import javax.validation.Valid; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; @@ -407,7 +408,7 @@ public class CallCenterUtils { /** * 获取指定活动,已分配的名单数 */ - public static int getActDisnum(@Valid String actid, @Valid int p, @Valid int ps) { + public static int getActDisnum(@Valid String actid, @Valid int p, @Valid int ps) throws IOException { BoolQueryBuilder queryBuilder = new BoolQueryBuilder(); queryBuilder.must(termQuery("actid", actid));// 活动ID queryBuilder.mustNot(termQuery("status", MainContext.NamesDisStatusType.NOT.toString())); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/DataProcess.java b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/DataProcess.java index 064975b1..758b97ec 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/DataProcess.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/DataProcess.java @@ -1,26 +1,30 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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.util.dsdata; - - -public abstract class DataProcess { - protected DSDataEvent event ; - public DataProcess(final DSDataEvent event){ - this.event = event ; - } - public abstract void process() ; -} +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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.util.dsdata; + + +import java.io.IOException; + +public abstract class DataProcess { + protected DSDataEvent event; + + public DataProcess(final DSDataEvent event) { + this.event = event; + } + + public abstract void process() throws IOException; +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/ExcelImportProecess.java b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/ExcelImportProecess.java index d6f54ec9..13811b80 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/ExcelImportProecess.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/ExcelImportProecess.java @@ -51,12 +51,12 @@ public class ExcelImportProecess extends DataProcess { } @Override - public void process() { + public void process() throws IOException { processExcel(event); } @SuppressWarnings({"unchecked", "rawtypes"}) - private void processExcel(final DSDataEvent event) { + private void processExcel(final DSDataEvent event) throws IOException { InputStream is = null; try { event.getDSData().getReport().setTableid(event.getDSData().getTask().getId()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/JPAProcess.java b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/JPAProcess.java index 22c290eb..52baaeca 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/JPAProcess.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/dsdata/process/JPAProcess.java @@ -1,22 +1,25 @@ -/* - * Copyright (C) 2017 优客服-多渠道客服系统 - * Modifications copyright (C) 2018-2019 Chatopera Inc, - * - * 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.util.dsdata.process; - -public interface JPAProcess { - public void process(Object data) ; - public void end(); -} +/* + * Copyright (C) 2017 优客服-多渠道客服系统 + * Modifications copyright (C) 2018-2019 Chatopera Inc, + * + * 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.util.dsdata.process; + +import java.io.IOException; + +public interface JPAProcess { + void process(Object data); + + void end() throws IOException; +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/es/SearchTools.java b/contact-center/app/src/main/java/com/chatopera/cc/util/es/SearchTools.java index 8c3dee8f..ddb4123d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/es/SearchTools.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/es/SearchTools.java @@ -30,6 +30,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; +import java.io.IOException; import java.util.List; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; @@ -37,7 +38,7 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery; public class SearchTools { - public static PageImpl search(String orgi, List itemList, MetadataTable metadataTable, boolean loadRef, int p, int ps) { + public static PageImpl search(String orgi, List itemList, MetadataTable metadataTable, boolean loadRef, int p, int ps) throws IOException { BoolQueryBuilder queryBuilder = new BoolQueryBuilder(); queryBuilder.must(termQuery("orgi", orgi)); @@ -96,7 +97,7 @@ public class SearchTools { return search(queryBuilder, metadataTable, loadRef, p, ps); } - public static PageImpl dissearch(String orgi, List itemList, MetadataTable metadataTable, int p, int ps) { + public static PageImpl dissearch(String orgi, List itemList, MetadataTable metadataTable, int p, int ps) throws IOException { BoolQueryBuilder queryBuilder = new BoolQueryBuilder(); queryBuilder.must(termQuery("orgi", orgi)); queryBuilder.must(termQuery("status", MainContext.NamesDisStatusType.NOT.toString())); @@ -156,7 +157,7 @@ public class SearchTools { return search(queryBuilder, metadataTable, false, p, ps); } - public static PageImpl recoversearch(String orgi, String cmd, String id, MetadataTable metadataTable, int p, int ps) { + public static PageImpl recoversearch(String orgi, String cmd, String id, MetadataTable metadataTable, int p, int ps) throws IOException { BoolQueryBuilder queryBuilder = new BoolQueryBuilder(); queryBuilder.must(termQuery("orgi", orgi)); queryBuilder.mustNot(termQuery("status", MainContext.NamesDisStatusType.NOT.toString())); @@ -198,7 +199,7 @@ public class SearchTools { /** * */ - public static PageImpl namesearch(String orgi, String phonenum) { + public static PageImpl namesearch(String orgi, String phonenum) throws IOException { BoolQueryBuilder queryBuilder = new BoolQueryBuilder(); queryBuilder.must(termQuery("orgi", orgi)); queryBuilder.must(termQuery("validresult", "valid")); @@ -219,14 +220,14 @@ public class SearchTools { /** * */ - public static PageImpl search(BoolQueryBuilder queryBuilder, int p, int ps) { + public static PageImpl search(BoolQueryBuilder queryBuilder, int p, int ps) throws IOException { return search(queryBuilder, null, true, p, ps); } /** * */ - private static PageImpl search(BoolQueryBuilder queryBuilder, MetadataTable metadataTable, boolean loadRef, int p, int ps) { + private static PageImpl search(BoolQueryBuilder queryBuilder, MetadataTable metadataTable, boolean loadRef, int p, int ps) throws IOException { ESDataExchangeImpl esDataExchange = MainContext.getContext().getBean(ESDataExchangeImpl.class); return esDataExchange.findPageResult(queryBuilder, metadataTable, PageRequest.of(p, ps, Sort.Direction.ASC, "createtime"), loadRef); } @@ -234,7 +235,7 @@ public class SearchTools { /** * */ - public static PageImpl aggregation(BoolQueryBuilder queryBuilder, String aggField, boolean loadRef, int p, int ps) { + public static PageImpl aggregation(BoolQueryBuilder queryBuilder, String aggField, boolean loadRef, int p, int ps) throws IOException { ESDataExchangeImpl esDataExchange = MainContext.getContext().getBean(ESDataExchangeImpl.class); return esDataExchange.findAllPageAggResult(queryBuilder, aggField, PageRequest.of(p, ps, Sort.Direction.ASC, "createtime"), loadRef, null); } @@ -242,7 +243,7 @@ public class SearchTools { /** * */ - public static UKDataBean get(UKDataBean dataBean) { + public static UKDataBean get(UKDataBean dataBean) throws IOException { ESDataExchangeImpl esDataExchange = MainContext.getContext().getBean(ESDataExchangeImpl.class); return esDataExchange.getIObjectByPK(dataBean); } @@ -250,7 +251,7 @@ public class SearchTools { /** * */ - public static UKDataBean get(String type, String id) { + public static UKDataBean get(String type, String id) throws IOException { ESDataExchangeImpl esDataExchange = MainContext.getContext().getBean(ESDataExchangeImpl.class); return esDataExchange.getIObjectByPK(type, id); }