1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-07-24 08:31:45 +08:00

https://github.com/chatopera/cosin/issues/373 release 春松客服 v6, 支持多组织,多管理员

This commit is contained in:
Hai Liang Wang 2020-10-29 16:41:58 +08:00
parent b2fde6a81f
commit 6974275b55
302 changed files with 7116 additions and 11039 deletions

1
.gitignore vendored
View File

@ -19,4 +19,5 @@ backups/
.env
build.gradle
.vscode/
nohup.out
private

View File

@ -1,13 +1,6 @@
Copyright 2018-2020 Chatopera Inc. <https://www.chatopera.com>. All rights reserved.
Copyright (2018-2020) Chatopera Inc. <https://www.chatopera.com>. All rights reserved.
This software and related documentation are provided under a license agreement containing
restrictions on use and disclosure and are protected by intellectual property laws.
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
Except as expressly permitted in your license agreement or allowed by law, you may not use,
copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform,
publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,

View File

@ -122,9 +122,9 @@ The collaboration is efficient, very professional. The software is steady with h
寻找开发者合作智能客服项目,社区共建,携手共赢!
* 组织或个人,在春松客服主页展示为认证开发者
* 春松客服官方推荐项目机会
* 专访并通过官方渠道曝光
- 组织或个人,在春松客服主页展示为认证开发者
- 春松客服官方推荐项目机会
- 专访并通过官方渠道曝光
填写申请:[https://www.wjx.top/jq/93397428.aspx](https://www.wjx.top/jq/93397428.aspx)
@ -135,8 +135,6 @@ The collaboration is efficient, very professional. The software is steady with h
<img src="https://static-public.chatopera.com/assets/images/44915395-6bff5d80-ad65-11e8-817a-8abb812fb5ee.png" width="900">
</p>
<details>
<summary>展开查看更多产品截图</summary>
<p>
@ -185,7 +183,6 @@ The collaboration is efficient, very professional. The software is steady with h
参考部署[开源社区版本文档](https://docs.chatopera.com/products/cskefu/deploy.html)。
## 鸣谢
[FreeSWITCH 中国社区](http://www.freeswitch.org.cn/)
@ -201,8 +198,6 @@ Copyright (2018-2020) <a href="https://www.chatopera.com/" target="_blank">北
[co-banner-image]: https://static-public.chatopera.com/assets/images/42383104-da925942-8168-11e8-8195-868d5fcec170.png
[co-url]: https://www.chatopera.com
## Chatopera 云服务
[https://bot.chatopera.com/](https://bot.chatopera.com/)
@ -263,7 +258,6 @@ Chatopera 机器人平台包括知识库、多轮对话、意图识别和语音
</p>
</details>
<p align="center">
<b>立即使用</b><br>
<a href="https://bot.chatopera.com" target="_blank">

View File

@ -1,6 +1,8 @@
app/target
!app/target/*.war.original
!app/target/*.war
!app/target/*.jar.original
!app/target/*.jar
logs/
tmp/
data/

View File

@ -38,7 +38,7 @@ RUN /bin/bash -c "mkdir -p /{data,logs}"
# build WAR
RUN mkdir -p /opt/chatopera
COPY ./app/target/contact-center-*.war /opt/chatopera/contact-center.war
COPY ./app/target/contact-center.war /opt/chatopera/contact-center.war
COPY ./assets/mysql.setup.db.sh /opt/chatopera
COPY ./assets/mysql.upgrade.db.sh /opt/chatopera
COPY ./assets/utils.sh /opt/chatopera

View File

@ -29,4 +29,11 @@ docker build --build-arg VCS_REF=$PACKAGE_VERSION \
--build-arg APPLICATION_BUILD_DATESTR=$TIMESTAMP \
--build-arg APPLICATION_CUSTOMER_ENTITY=$APPLICATION_CUSTOMER_ENTITY \
--no-cache \
--force-rm=true --tag $registryName/$imagename:$PACKAGE_VERSION .
--force-rm=true --tag $registryName/$imagename:$PACKAGE_VERSION .
if [ $? -eq 0 ]; then
docker tag $registryName/$imagename:$PACKAGE_VERSION $registryName/$imagename:develop
else
echo "Build contact-center failure."
exit 1
fi

50
contact-center/admin/deploy.sh Executable file
View File

@ -0,0 +1,50 @@
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
REPO_ID_SNP=chatopera-snapshots
REPO_URL_SNP=https://nexus.chatopera.com/repository/maven-snapshots/
REPO_ID_REL=chatopera-releases
REPO_URL_REL=https://nexus.chatopera.com/repository/maven-releases/
# functions
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn clean jar:jar
PACKAGE_VERSION=$(grep --max-count=1 '<version>' pom.xml | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }')
if [[ $PACKAGE_VERSION == *SNAPSHOT ]]; then
echo "Deploy as snapshot package ..."
mvn deploy:deploy-file \
-Dmaven.test.skip=true \
-Dfile=./target/contact-center.jar \
-DgroupId=com.chatopera.cc \
-DartifactId=cc-core \
-Dversion=$PACKAGE_VERSION \
-Dpackaging=jar \
-DgeneratePom=true \
-DrepositoryId=$REPO_ID_SNP \
-Durl=$REPO_URL_SNP
if [ ! $? -eq 0 ]; then
exit 1
fi
else
echo "Deploy as release package ..."
mvn deploy:deploy-file \
-Dmaven.test.skip=true \
-Dfile=./target/contact-center.jar \
-DgroupId=com.chatopera.cc \
-DartifactId=cc-core \
-Dversion=$PACKAGE_VERSION \
-Dpackaging=jar \
-DgeneratePom=true \
-DrepositoryId=$REPO_ID_REL \
-Durl=$REPO_URL_REL
if [ ! $? -eq 0 ]; then
exit 1
fi
fi

View File

@ -1,30 +0,0 @@
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
if [ -f $baseDir/localrc ]; then
echo "Load localrc for environment variables ..."
set -x
source $baseDir/localrc
else
echo $baseDir/localrc "not exist."
echo "First, copy and modify the rc template."
echo "cp " $baseDir/localrc.sample $baseDir/localrc
exit 1
fi
# functions
function start(){
cd $baseDir/../app
mvn spring-boot:run
}
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
start

View File

@ -0,0 +1,47 @@
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
SCRIPT_PATH=$0
ts=`date +"%Y-%m-%d_%H-%M-%S"`
buildDir=/tmp/cc-build-$ts
# functions
function print_usage(){
echo "Install contact-center plugin: $SCRIPT_PATH contact-center_jar_path plugin_path output_path"
}
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
if [ "$#" -ne 4 ]; then
CONTACT_CENTER=$1
CC_PLUGIN=$2
OUTPUT_PATH=$3
if [ ! -f $1 ]; then
echo "contact center jar file not exist."
print_usage
exit 1
fi
if [ ! -f $2 ]; then
echo "cc plugin jar file not exist."
print_usage
exit 2
fi
# create jar
rm -rf $buildDir
mkdir $buildDir
unzip $CONTACT_CENTER -d $buildDir
cp $CC_PLUGIN $buildDir/BOOT-INF/lib
cd $buildDir
jar -cvfM0 $3 .
echo "Created new jar file as" $OUTPUT_PATH "successfully."
echo "Build done, delete buildDir" $buildDir "in 3 seconds ..."
sleep 3
rm -rf $buildDir
else
print_usage
fi

View File

@ -1,19 +0,0 @@
export SERVER_PORT=8035
export SERVER_LOG_PATH=$baseDir/../logs
# Log Level: INFO, DEBUG, ERROR, STDOUT
export SERVER_LOG_LEVEL=INFO
export WEB_UPLOAD_PATH=$baseDir/../data
export SPRING_FREEMARKER_CACHE=false
export SPRING_DATA_ELASTICSEARCH_PROPERTIES_PATH_DATA=$baseDir/../data
export UK_IM_SERVER_PORT=8036
export UK_IM_SERVER_HOST=localhost
export UK_IM_SERVER_THREADS=10
export SPRING_DATASOURCE_TYPE=com.alibaba.druid.pool.DruidDataSource
export SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.jdbc.Driver
export SPRING_DATASOURCE_URL=jdbc:mysql://localhost:8889/ukefu-test?useUnicode=true&characterEncoding=UTF-8
export SPRING_DATASOURCE_USERNAME=root
export SPRING_DATASOURCE_PASSWORD=root
export MANAGEMENT_SECURITY_ENABLED=false
export SPRING_REDIS_DATABASE=2
export SPRING_REDIS_HOST=redis
export SPRING_REDIS_PORT=6379

View File

@ -10,7 +10,9 @@ baseDir=$(cd `dirname "$0"`;pwd)
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn clean package
mvn -DskipTests clean package
# take too long time with dev002 for uploading artifact, skip this operation
# $baseDir/deploy.app.sh
if [ ! $? -eq 0 ]; then
exit 1

View File

@ -5,12 +5,17 @@
# constants
baseDir=$(cd `dirname "$0"`;pwd)
appHome=$baseDir/..
registryName=dockerhub.qingcloud.com
imagename=chatopera/contact-center
PACKAGE_VERSION=w4l
# functions
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
docker push $registryName/$imagename:$PACKAGE_VERSION
# build
cd $appHome
PACKAGE_VERSION=`git rev-parse --short HEAD`
docker push $registryName/$imagename:$PACKAGE_VERSION
docker push $registryName/$imagename:develop

View File

@ -9,5 +9,5 @@ baseDir=$(cd `dirname "$0"`;pwd)
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir/../app
mvn eclipse:eclipse
cd $baseDir/../root
mvn deploy

View File

@ -0,0 +1,12 @@
#! /bin/bash
###########################################
#
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
# functions
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
rm -rf ~/.m2/repository/com/chatopera/cc

View File

@ -1,9 +1,6 @@
# dev profile
src/main/resources/application-dev.properties
# ignore plugins source code
src/main/java/com/chatopera/cc/plugins/
# ignore channel views within plugins
src/main/resources/templates/admin/channel/*
!src/main/resources/templates/admin/channel/im
@ -11,3 +8,5 @@ src/main/resources/templates/admin/channel/*
# ignore app views within plugins
src/main/resources/templates/apps/callout
src/main/resources/templates/apps/chatbot
src/main/resources/templates/apps/callcenter
logs/

View File

@ -3,382 +3,31 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.chatopera.cc</groupId>
<artifactId>contact-center</artifactId>
<version>5.1.0</version>
<packaging>war</packaging>
<name>cskefu</name>
<name>cc-core</name>
<description>春松客服:多渠道智能客服系统</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<groupId>com.chatopera.cc</groupId>
<artifactId>cc-root</artifactId>
<version>6.0.0-SNAPSHOT</version>
<relativePath/>
<!-- for local reference if file is available with latest version -->
<!-- <relativePath>../cc-root/pom.xml</relativePath> -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.14.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.29</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>1.5.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>lt.jave</groupId>
<artifactId>jave</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Hypermedia for actuator MVC endpoints -->
<!-- https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/production-ready-endpoints.html#production-ready-endpoint-hypermedia -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<!-- Micrometer Prometheus registry -->
<!-- https://www.callicoder.com/spring-boot-actuator-metrics-monitoring-dashboard-prometheus-grafana/ -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-spring-legacy</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<!-- AOP dependencies -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.27</version>
</dependency>
<dependency>
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-dbutils/commons-dbutils -->
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.odysseus.juel/juel-impl -->
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
<version>2.2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.1-atlassian-hosted</version>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.olap4j</groupId>
<artifactId>olap4j</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>mondrian</groupId>
<artifactId>mondrian</artifactId>
<version>3.7.0</version>
</dependency>
<!-- Distribute Storage Service https://github.com/minio/minio-java -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>5.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.aviator/aviator -->
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>3.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-core -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
<dependency>
<groupId>com.chatopera.compose4j</groupId>
<artifactId>compose4j</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.chatopera.bot</groupId>
<artifactId>sdk</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>contact-center</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
@ -436,7 +85,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
@ -463,7 +111,6 @@
</configuration>
<version>2.1.1</version>
</plugin>
</plugins>
<defaultGoal>compile</defaultGoal>
</build>
@ -471,7 +118,7 @@
<repository>
<id>chatopera</id>
<name>Chatopera Inc.</name>
<url>https://nexus.chatopera.com/repository/maven-public</url>
<url>https://nexus.chatopera.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>

View File

@ -22,6 +22,8 @@ import com.chatopera.cc.basic.plugins.PluginRegistry;
import com.chatopera.cc.config.AppCtxRefreshEventListener;
import com.chatopera.cc.util.SystemEnvHelper;
import com.chatopera.cc.util.mobile.MobileNumberUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -36,8 +38,6 @@ import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.servlet.MultipartConfigElement;
@ -65,41 +65,46 @@ public class Application {
*/
static {
// CRM模块
MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.contacts"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CONTACTS);
}
// 会话监控模块 Customer Chats Audit
MainContext.enableModule(Constants.CSKEFU_MODULE_CCA);
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.cca"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CCA);
}
// 企业聊天模块
MainContext.enableModule(Constants.CSKEFU_MODULE_ENTIM);
/**
* 插件组
*/
// 外呼模块
if (SystemEnvHelper.isClassExistByFullName(
PluginRegistry.PLUGIN_ENTRY_CALLOUT)) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CALLOUT);
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.entim"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_ENTIM);
}
// skype模块
if (SystemEnvHelper.isClassExistByFullName(
PluginRegistry.PLUGIN_ENTRY_SKYPE)) {
MainContext.enableModule(Constants.CSKEFU_MODULE_SKYPE);
// 数据报表
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.report"), "true")) {
MainContext.enableModule(Constants.CSKEFU_MODULE_REPORT);
}
// 聊天机器人模块
if (SystemEnvHelper.isClassExistByFullName(PluginRegistry.PLUGIN_ENTRY_CHATBOT)) {
MainContext.enableModule(Constants.CSKEFU_MODULE_CHATBOT);
}
}
/**
* Init local resources
*/
protected static void init() {
protected static void serve(final String[] args) {
try {
MobileNumberUtils.init();
/************************
* 该APP中加载多个配置文件
* http://roufid.com/load-multiple-configuration-files-different-directories-spring-boot/
************************/
SpringApplication app = new SpringApplicationBuilder(Application.class)
.properties("spring.config.name:application,git")
.build();
app.setBannerMode(Banner.Mode.CONSOLE);
app.setAddCommandLineProperties(false);
app.addListeners(new AppCtxRefreshEventListener());
MainContext.setApplicationContext(app.run(args));
} catch (IOException e) {
logger.error("Application Startup Error", e);
System.exit(1);
@ -127,19 +132,6 @@ public class Application {
}
public static void main(String[] args) {
Application.init();
/************************
* 该APP中加载多个配置文件
* http://roufid.com/load-multiple-configuration-files-different-directories-spring-boot/
************************/
SpringApplication app = new SpringApplicationBuilder(Application.class)
.properties("spring.config.name:application,git")
.build();
app.setBannerMode(Banner.Mode.CONSOLE);
app.setAddCommandLineProperties(false);
app.addListeners(new AppCtxRefreshEventListener());
MainContext.setApplicationContext(app.run(args));
Application.serve(args);
}
}

View File

@ -40,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Component
@ -183,9 +184,9 @@ public class ACDAgentService {
// 获得所有待服务访客的列表
final Map<String, AgentUser> pendingAgentUsers = cache.getAgentUsersInQueByOrgi(orgi);
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
// 本次批量分配访客数目
int assigned = 0;
Map<String, Integer> assigned = new HashMap<>();
int currentAssigned = cache.getInservAgentUsersSizeByAgentnoAndOrgi(
agentStatus.getAgentno(), agentStatus.getOrgi());
@ -226,14 +227,15 @@ public class ACDAgentService {
}
// 坐席未达到最大咨询访客数量并且单次批量分配小于坐席就绪时分配最大访客数量(initMaxuser)
if (((currentAssigned + assigned) < sessionConfig.getMaxuser()) && (assigned < sessionConfig.getInitmaxuser())) {
assigned++;
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(agentUser.getSkill(), orgi);
if ((ACDServiceRouter.getAcdPolicyService().getAgentUsersBySkill(agentStatus, agentUser.getSkill()) < sessionConfig.getMaxuser()) && (assigned.getOrDefault(agentUser.getSkill(), 0) < sessionConfig.getInitmaxuser())) {
assigned.merge(agentUser.getSkill(), 1, Integer::sum);
pickupAgentUserInQueue(agentUser, agentStatus);
} else {
logger.info(
"[assignVisitors] agentno {} reach the max users limit {}/{} or batch assign limit {}/{}",
agentno,
(currentAssigned + assigned),
(currentAssigned + assigned.getOrDefault(agentUser.getSkill(), 0)),
sessionConfig.getMaxuser(), assigned, sessionConfig.getInitmaxuser());
break;
}
@ -282,6 +284,9 @@ public class ACDAgentService {
peerSyncIM.send(MainContext.ReceiverType.AGENT, MainContext.ChannelType.WEBIM,
agentUser.getAppid(),
MainContext.MessageType.NEW, agentUser.getAgentno(), outMessage, true);
// 通知更新在线数据
agentStatusProxy.broadcastAgentsStatus(agentUser.getOrgi(), "agent", "pickup", agentStatus.getAgentno());
}
} catch (Exception ex) {
logger.warn("[assignVisitors] fail to process service", ex);
@ -317,7 +322,7 @@ public class ACDAgentService {
// 从缓存中删除agentUser缓存
agentUserRes.save(agentUser);
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
final SessionConfig sessionConfig = acdPolicyService.initSessionConfig(agentUser.getSkill(), orgi);
/**
* 坐席服务
@ -384,7 +389,7 @@ public class ACDAgentService {
// 向访客发送消息
Message outMessage = new Message();
outMessage.setAgentStatus(agentStatus);
outMessage.setMessage(acdMessageHelper.getServiceFinishMessage(agentUser.getChannel(), orgi));
outMessage.setMessage(acdMessageHelper.getServiceFinishMessage(agentUser.getChannel(), agentUser.getSkill(), orgi));
outMessage.setMessageType(MainContext.AgentUserStatusEnum.END.toString());
outMessage.setCalltype(MainContext.CallType.IN.toString());
outMessage.setCreatetime(MainUtils.dateFormate.format(new Date()));
@ -432,7 +437,7 @@ public class ACDAgentService {
// 当前访客服务已经结束为坐席寻找新访客
if (agentStatus != null) {
if ((agentStatus.getUsers() - 1) < sessionConfig.getMaxuser()) {
if ((ACDServiceRouter.getAcdPolicyService().getAgentUsersBySkill(agentStatus, agentUser.getSkill()) - 1) < sessionConfig.getMaxuser()) {
assignVisitors(agentStatus.getAgentno(), orgi);
}
}

View File

@ -16,12 +16,14 @@
package com.chatopera.cc.acd;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.AgentUser;
import com.chatopera.cc.model.SessionConfig;
import com.chatopera.cc.persistence.repository.AgentUserRepository;
import com.chatopera.cc.persistence.repository.OnlineUserRepository;
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
import com.chatopera.cc.util.HashMapUtils;
@ -33,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@ -52,6 +55,9 @@ public class ACDPolicyService {
@Autowired
private OnlineUserRepository onlineUserRes;
@Autowired
private AgentUserRepository agentUserRes;
/**
* 载入坐席 ACD策略配置
*
@ -60,10 +66,10 @@ public class ACDPolicyService {
@SuppressWarnings("unchecked")
public List<SessionConfig> initSessionConfigList() {
List<SessionConfig> sessionConfigList;
if ((sessionConfigList = cache.findOneSessionConfigListByOrgi(MainContext.SYSTEM_ORGI)) == null) {
if ((sessionConfigList = cache.findOneSessionConfigListByOrgi(Constants.SYSTEM_ORGI)) == null) {
sessionConfigList = sessionConfigRes.findAll();
if (sessionConfigList != null && sessionConfigList.size() > 0) {
cache.putSessionConfigListByOrgi(sessionConfigList, MainContext.SYSTEM_ORGI);
cache.putSessionConfigListByOrgi(sessionConfigList, Constants.SYSTEM_ORGI);
}
}
return sessionConfigList;
@ -75,14 +81,14 @@ public class ACDPolicyService {
* @param orgi
* @return
*/
public SessionConfig initSessionConfig(final String orgi) {
public SessionConfig initSessionConfig(String organid, final String orgi) {
SessionConfig sessionConfig;
if ((sessionConfig = cache.findOneSessionConfigByOrgi(orgi)) == null) {
sessionConfig = sessionConfigRes.findByOrgi(orgi);
if ((sessionConfig = cache.findOneSessionConfigByOrgi(organid, orgi)) == null) {
sessionConfig = sessionConfigRes.findByOrgiAndSkill(orgi, organid);
if (sessionConfig == null) {
sessionConfig = new SessionConfig();
} else {
cache.putSessionConfigByOrgi(sessionConfig, orgi);
cache.putSessionConfigByOrgi(sessionConfig, organid, orgi);
}
}
@ -113,14 +119,7 @@ public class ACDPolicyService {
*/
public AgentStatus decideAgentStatusInAverage(final List<AgentStatus> agentStatuses) {
// 查找最少人数的AgentStatus
AgentStatus x = null;
int min = 0;
for (final AgentStatus o : agentStatuses) {
if ((x == null) || (o.getUsers() < min)) {
x = o;
min = o.getUsers();
}
}
AgentStatus x = agentStatuses.stream().min(Comparator.comparingInt(AgentStatus::getUsers)).get();
if (x != null) {
logger.info("[decideAgentStatusWithIdleAgent] choose agentno {} in average.", x.getAgentno());
@ -144,7 +143,7 @@ public class ACDPolicyService {
logger.info(
"[filterOutAvailableAgentStatus] pre-conditions: agentUser.agentno {}, orgi {}, skill {}, onlineUser {}",
agentUser.getAgentno(), orgi, agentUser.getSkill(), agentUser.getUserid()
);
);
List<AgentStatus> agentStatuses = new ArrayList<>();
Map<String, AgentStatus> map = cache.findAllReadyAgentStatusByOrgi(orgi);
@ -155,10 +154,10 @@ public class ACDPolicyService {
for (final Map.Entry<String, AgentStatus> f : map.entrySet()) {
sb.append(
String.format(" name %s, agentno %s, service %d/%d, status %s, busy %s, skills %s \n",
f.getValue().getUsername(),
f.getValue().getAgentno(), f.getValue().getUsers(), f.getValue().getMaxusers(),
f.getValue().getStatus(), f.getValue().isBusy(),
HashMapUtils.concatKeys(f.getValue().getSkills(), "|")));
f.getValue().getUsername(),
f.getValue().getAgentno(), f.getValue().getUsers(), f.getValue().getMaxusers(),
f.getValue().getStatus(), f.getValue().isBusy(),
HashMapUtils.concatKeys(f.getValue().getSkills(), "|")));
}
logger.info(sb.toString());
} else {
@ -198,7 +197,7 @@ public class ACDPolicyService {
// 指定技能组
for (final Map.Entry<String, AgentStatus> entry : map.entrySet()) {
if ((!entry.getValue().isBusy()) &&
(entry.getValue().getUsers() < sessionConfig.getMaxuser()) &&
(getAgentUsersBySkill(entry.getValue(), agentUser.getSkill()) < sessionConfig.getMaxuser()) &&
(entry.getValue().getSkills() != null &&
entry.getValue().getSkills().containsKey(agentUser.getSkill()))) {
logger.info(
@ -227,26 +226,28 @@ public class ACDPolicyService {
/**
* 在指定的坐席和技能组中未查到坐席
* 接下来进行无差别查询
*
* TODO 指定技能组无用户停止分配
*/
// 对于该租户的所有客服
for (final Map.Entry<String, AgentStatus> entry : map.entrySet()) {
if ((!entry.getValue().isBusy()) && (entry.getValue().getUsers() < sessionConfig.getMaxuser())) {
agentStatuses.add(entry.getValue());
logger.info(
"[filterOutAvailableAgentStatus] <Redundance> find ready agent {}, agentname {}, status {}, service {}/{}, skills {}",
entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
entry.getValue().getUsers(),
entry.getValue().getMaxusers(),
HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
} else {
logger.info(
"[filterOutAvailableAgentStatus] <Redundance> skip ready agent {}, name {}, status {}, service {}/{}, skills {}",
entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
entry.getValue().getUsers(),
entry.getValue().getMaxusers(),
HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
}
}
// for (final Map.Entry<String, AgentStatus> entry : map.entrySet()) {
// if ((!entry.getValue().isBusy()) && (entry.getValue().getUsers() < sessionConfig.getMaxuser())) {
// agentStatuses.add(entry.getValue());
// logger.info(
// "[filterOutAvailableAgentStatus] <Redundance> find ready agent {}, agentname {}, status {}, service {}/{}, skills {}",
// entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
// entry.getValue().getUsers(),
// entry.getValue().getMaxusers(),
// HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
// } else {
// logger.info(
// "[filterOutAvailableAgentStatus] <Redundance> skip ready agent {}, name {}, status {}, service {}/{}, skills {}",
// entry.getValue().getAgentno(), entry.getValue().getUsername(), entry.getValue().getStatus(),
// entry.getValue().getUsers(),
// entry.getValue().getMaxusers(),
// HashMapUtils.concatKeys(entry.getValue().getSkills(), "|"));
// }
// }
}
logger.info("[filterOutAvailableAgentStatus] agent status list size: {}", agentStatuses.size());
@ -292,11 +293,11 @@ public class ACDPolicyService {
logger.info("[filterOutAgentStatusWithPolicies] check agent against chat history.");
// 启用了历史坐席优先 查找 历史服务坐席
List<com.chatopera.cc.util.WebIMReport> webIMaggs = MainUtils.getWebIMDataAgg(
onlineUserRes.findByOrgiForDistinctAgent(orgi, onlineUserId));
onlineUserRes.findBySkillAndOrgiForDistinctAgent(sessionConfig.getSkill(), orgi, onlineUserId));
for (WebIMReport report : webIMaggs) {
for (final AgentStatus o : agentStatuses) {
if (StringUtils.equals(
o.getAgentno(), report.getData()) && o.getUsers() < sessionConfig.getMaxuser()) {
o.getAgentno(), report.getData()) && getAgentUsersBySkill(o, sessionConfig.getSkill()) < sessionConfig.getMaxuser()) {
agentStatus = o;
logger.info(
"[filterOutAgentStatusWithPolicies] choose agentno {} by chat history.",
@ -349,4 +350,8 @@ public class ACDPolicyService {
return agentStatus;
}
public int getAgentUsersBySkill(AgentStatus agentStatus, String skill) {
return agentUserRes.countByAgentnoAndStatusAndOrgiAndSkill(agentStatus.getAgentno(), MainContext.AgentUserStatusEnum.INSERVICE.toString(), agentStatus.getOrgi(), skill);
}
}

View File

@ -20,8 +20,12 @@ import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentReport;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.WorkMonitor;
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.persistence.repository.AgentUserRepository;
import com.chatopera.cc.persistence.repository.WorkMonitorRepository;
import com.chatopera.cc.proxy.OrganProxy;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -42,6 +46,15 @@ public class ACDWorkMonitor {
@Autowired
private Cache cache;
@Autowired
private OrganProxy organProxy;
@Autowired
private AgentServiceRepository agentServiceRes;
@Autowired
private AgentUserRepository agentUserRes;
/**
* 获得 当前服务状态
*
@ -96,16 +109,26 @@ public class ACDWorkMonitor {
/**
* 统计当前服务中的用户数量
*/
// 服务中
report.setUsers(cache.getInservAgentUsersSizeByOrgi(orgi));
// 等待中
report.setInquene(cache.getInqueAgentUsersSizeByOrgi(orgi));
if (organ != null) {
Organ currentOrgan = new Organ();
currentOrgan.setId(organ);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, orgi);
report.setUsers(agentServiceRes.countByOrgiAndStatusAndAgentskillIn(orgi, MainContext.AgentUserStatusEnum.INSERVICE.toString(), organs.keySet()));
report.setInquene(agentUserRes.countByOrgiAndStatusAndSkillIn(orgi, MainContext.AgentUserStatusEnum.INQUENE.toString(), organs.keySet()));
} else {
// 服务中
report.setUsers(cache.getInservAgentUsersSizeByOrgi(orgi));
// 等待中
report.setInquene(cache.getInqueAgentUsersSizeByOrgi(orgi));
}
// DEBUG
logger.info(
"[getAgentReport] orgi {}, organ {}, agents {}, busy {}, users {}, inqueue {}", orgi, organ,
report.getAgents(), report.getBusy(), report.getUsers(), report.getInquene()
);
);
return report;
}
@ -129,7 +152,7 @@ public class ACDWorkMonitor {
String worktype,
String orgi,
Date lasttime
) {
) {
WorkMonitor workMonitor = new WorkMonitor();
if (StringUtils.isNotBlank(agent) && StringUtils.isNotBlank(status)) {
workMonitor.setAgent(agent);
@ -149,7 +172,7 @@ public class ACDWorkMonitor {
int count = workMonitorRes.countByAgentAndDatestrAndStatusAndOrgi(
agent, MainUtils.simpleDateFormat.format(new Date()),
MainContext.AgentStatusEnum.READY.toString(), orgi
);
);
if (count == 0) {
workMonitor.setFirsttime(true);
}

View File

@ -86,7 +86,7 @@ public class ACDMessageHelper {
if (!MainContext.ChannelType.WEBIM.toString().equals(channel)) {
queneTip = agentService.getAgentusername();
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(agentService.getSkill(), orgi);
String successMsg = "坐席分配成功," + queneTip + "为您服务。";
if (StringUtils.isNotBlank(sessionConfig.getSuccessmsg())) {
successMsg = sessionConfig.getSuccessmsg().replaceAll("\\{agent\\}", queneTip);
@ -101,8 +101,8 @@ public class ACDMessageHelper {
* @param orgi
* @return
*/
public String getServiceFinishMessage(String channel, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
public String getServiceFinishMessage(String channel, String organid, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String queneTip = "坐席已断开和您的对话";
if (StringUtils.isNotBlank(sessionConfig.getFinessmsg())) {
queneTip = sessionConfig.getFinessmsg();
@ -118,8 +118,8 @@ public class ACDMessageHelper {
* @param orgi
* @return
*/
public String getServiceOffMessage(String channel, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
public String getServiceOffMessage(String channel, String organid, String orgi) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String queneTip = "坐席已断开和您的对话,刷新页面为您分配新的坐席";
if (StringUtils.isNotBlank(sessionConfig.getFinessmsg())) {
queneTip = sessionConfig.getFinessmsg();
@ -127,7 +127,7 @@ public class ACDMessageHelper {
return queneTip;
}
public String getNoAgentMessage(int queneIndex, String channel, String orgi) {
public String getNoAgentMessage(int queneIndex, String channel, String organid, String orgi) {
if (queneIndex < 0) {
queneIndex = 0;
}
@ -135,7 +135,7 @@ public class ACDMessageHelper {
if (!MainContext.ChannelType.WEBIM.toString().equals(channel)) {
queneTip = String.valueOf(queneIndex);
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String noAgentTipMsg = "坐席全忙,已进入等待队列,您也可以在其他时间再来咨询。";
if (StringUtils.isNotBlank(sessionConfig.getNoagentmsg())) {
noAgentTipMsg = sessionConfig.getNoagentmsg().replaceAll("\\{num\\}", queneTip);
@ -143,13 +143,13 @@ public class ACDMessageHelper {
return noAgentTipMsg;
}
public String getQueneMessage(int queneIndex, String channel, String orgi) {
public String getQueneMessage(int queneIndex, String channel, String organid, String orgi) {
String queneTip = "<span id='queneindex'>" + queneIndex + "</span>";
if (!MainContext.ChannelType.WEBIM.toString().equals(channel)) {
queneTip = String.valueOf(queneIndex);
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(organid, orgi);
String agentBusyTipMsg = "正在排队,请稍候,在您之前,还有 " + queneTip + " 位等待用户。";
if (StringUtils.isNotBlank(sessionConfig.getAgentbusymsg())) {
agentBusyTipMsg = sessionConfig.getAgentbusymsg().replaceAll("\\{num\\}", queneTip);

View File

@ -182,6 +182,7 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
ctx.setMessage(acdMessageHelper.getQueneMessage(
ctx.getAgentService().getQueneindex(),
ctx.getAgentUser().getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
} else {
// TODO 什么是否返回 noAgentMessage, 是否在是 INQUENE getQueneindex == 0
@ -190,6 +191,7 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
ctx.setMessage(acdMessageHelper.getNoAgentMessage(
ctx.getAgentService().getQueneindex(),
ctx.getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
}

View File

@ -59,6 +59,7 @@ public class ACDVisServiceMw implements Middleware<ACDComposeContext> {
acdMessageHelper.getQueneMessage(
queueIndex,
ctx.getChannel(),
ctx.getOrganid(),
ctx.getOrgi()));
break;
case INSERVICE:

View File

@ -45,7 +45,7 @@ public class ACDVisSessionCfgMw implements Middleware<ACDComposeContext> {
@Override
public void apply(final ACDComposeContext ctx, final Functional next) {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(ctx.getOrganid(),
ctx.getOrgi());
ctx.setSessionConfig(sessionConfig);

View File

@ -29,7 +29,9 @@ public class Constants {
/**
* 系统配置
*/
public static final String SYSTEM_ORGI = "cskefu";
public static final String USER_SESSION_NAME = "user";
public static final String ORGAN_SESSION_NAME = "organ";
public static final String GUEST_USER = "guest";
public static final String IM_USER_SESSION_NAME = "im_user";
public static final String CSKEFU_SYSTEM_DIC = "com.dic.system.template";
@ -45,7 +47,6 @@ public class Constants {
public static final String CSKEFU_SYSTEM_DIS_TIME = "distime";
public static final String CSKEFU_SYSTEM_COOKIES_FLAG = "uk_flagid";
public static final String CSKEFU_SYSTEM_NO_DAT = "NOTEXIST";
public static final String SYSTEM_INDEX = "cskefu";
public static final String CSKEFU_SYSTEM_SECFIELD = "cskefu_sec_field";
public static final String CSKEFU_SYSTEM_CALLCENTER = "callcenter";
@ -92,6 +93,7 @@ public class Constants {
public final static String CSKEFU_MODULE_ENTIM = "entim";
public final static String CSKEFU_MODULE_WORKORDERS = "workorders";
public final static String CSKEFU_MODULE_CALLCENTER = "callcenter";
public final static String CSKEFU_MODULE_REPORT = "report";
/**
* Formatter
@ -136,6 +138,10 @@ public class Constants {
/**
* FreeSwitch Communication
*/
// callcenter
public final static String ACTIVEMQ_QUEUE_SWITCH_SYNC = "cskefu.callcenter.switch.sync";
// callout
public final static String FS_SIP_STATUS = "pbx:%s:sips"; // 查询SIP状态
public final static String FS_CHANNEL_CC_TO_FS = "pbx/%s/execute"; // 发送外呼执行信号
public final static String FS_DIALPLAN_STATUS = "pbx:%s:status"; // 外呼执行状态存储

View File

@ -43,8 +43,6 @@ public class MainContext {
private static boolean imServerRunning = false; // IM服务状态
public static String SYSTEM_ORGI = "cskefu";
private static Set<String> modules = new HashSet<String>();
public static Map<String, Class<?>> csKeFuResourceMap = new HashMap<String, Class<?>>();
@ -61,13 +59,10 @@ public class MainContext {
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;
@ -435,7 +430,10 @@ public class MainContext {
}
}
public enum ExtentionType {
/**
* 分机类型
*/
public enum ExtensionType {
LINE,
IVR,
BUSINESS,
@ -446,6 +444,15 @@ public class MainContext {
public String toString() {
return super.toString().toLowerCase();
}
public static ExtensionType toValue(final String str) {
for (final ExtensionType item : values()) {
if (StringUtils.equalsIgnoreCase(item.toString(), str)) {
return item;
}
}
throw new IllegalArgumentException();
}
}
public enum DTMFType {

View File

@ -763,7 +763,7 @@ public class MainUtils {
public static String processEmoti(String message) {
Pattern pattern = Pattern.compile("\\[([\\d]*?)\\]");
SystemConfig systemConfig = MainContext.getCache().findOneSystemByIdAndOrgi(
"systemConfig", MainContext.SYSTEM_ORGI);
"systemConfig", Constants.SYSTEM_ORGI);
Matcher matcher = pattern.matcher(message);
StringBuffer strb = new StringBuffer();
@ -839,10 +839,10 @@ public class MainUtils {
*/
public static SystemConfig getSystemConfig() {
SystemConfig systemConfig = MainContext.getCache().findOneSystemByIdAndOrgi(
"systemConfig", MainContext.SYSTEM_ORGI);
"systemConfig", Constants.SYSTEM_ORGI);
if (systemConfig == null) {
SystemConfigRepository systemConfigRes = MainContext.getContext().getBean(SystemConfigRepository.class);
systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
systemConfig = systemConfigRes.findByOrgi(Constants.SYSTEM_ORGI);
}
return systemConfig;
}
@ -856,7 +856,7 @@ public class MainUtils {
if (tpRes != null) {
List<TableProperties> tpList = tpRes.findBySecfield(true);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_SECFIELD, MainContext.SYSTEM_ORGI, tpList);
Constants.CSKEFU_SYSTEM_SECFIELD, Constants.SYSTEM_ORGI, tpList);
}
}
@ -866,10 +866,10 @@ public class MainUtils {
* @return
*/
public static void initSystemArea() {
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_AREA, MainContext.SYSTEM_ORGI);
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_AREA, Constants.SYSTEM_ORGI);
AreaTypeRepository areaTypeRes = MainContext.getContext().getBean(AreaTypeRepository.class);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_AREA, MainContext.SYSTEM_ORGI, areaTypeRes.findAll());
Constants.CSKEFU_SYSTEM_AREA, Constants.SYSTEM_ORGI, areaTypeRes.findAll());
}
/**
@ -877,19 +877,19 @@ public class MainUtils {
*
* @return
*/
public static void initAdv(String orgi) {
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi);
public static void initAdv(String orgi, String skill) {
MainContext.getCache().deleteSystembyIdAndOrgi(Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi);
AdTypeRepository adRes = MainContext.getContext().getBean(AdTypeRepository.class);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi, adRes.findByOrgi(orgi));
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi, adRes.findByOrgiAndSkill(orgi, skill));
}
public static Template getTemplate(String id) {
Template templet = null;
if ((templet = MainContext.getCache().findOneSystemByIdAndOrgi(id, MainContext.SYSTEM_ORGI)) == null) {
if ((templet = MainContext.getCache().findOneSystemByIdAndOrgi(id, Constants.SYSTEM_ORGI)) == null) {
TemplateRepository templateRes = MainContext.getContext().getBean(TemplateRepository.class);
templet = templateRes.findByIdAndOrgi(id, MainContext.SYSTEM_ORGI);
MainContext.getCache().putSystemByIdAndOrgi(id, MainContext.SYSTEM_ORGI, templet);
templet = templateRes.findByIdAndOrgi(id, Constants.SYSTEM_ORGI);
MainContext.getCache().putSystemByIdAndOrgi(id, Constants.SYSTEM_ORGI, templet);
}
return templet;
}
@ -901,15 +901,15 @@ public class MainUtils {
* @return
*/
@SuppressWarnings("unchecked")
public static AdType getPointAdv(String adpos, String orgi) {
public static AdType getPointAdv(String adpos, String skill, String orgi) {
List<AdType> adTypeList = new ArrayList<AdType>();
List<AdType> cacheAdTypeList = MainContext.getCache().findOneSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi);
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi);
if (cacheAdTypeList == null) {
AdTypeRepository adRes = MainContext.getContext().getBean(AdTypeRepository.class);
cacheAdTypeList = adRes.findByOrgi(orgi);
cacheAdTypeList = adRes.findByOrgiAndSkill(orgi, skill);
MainContext.getCache().putSystemListByIdAndOrgi(
Constants.CSKEFU_SYSTEM_ADV + "_" + orgi, orgi, cacheAdTypeList);
Constants.CSKEFU_SYSTEM_ADV + "_" + skill, orgi, cacheAdTypeList);
}
List<SysDic> sysDicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_ADPOS_DIC);
SysDic sysDic = null;

View File

@ -0,0 +1,24 @@
package com.chatopera.cc.basic.plugins;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractPluginConfigurer implements IPluginConfigurer {
public abstract String getPluginId();
public abstract String getPluginName();
public abstract String getIOEventHandler();
public Map<String, String> getEnvironmentVariables() {
Map<String, String> env = new HashMap<>();
return env;
}
public boolean isModule() {
return false;
}
public abstract void setup();
}

View File

@ -17,9 +17,22 @@ package com.chatopera.cc.basic.plugins;
import java.util.Map;
public interface IPluginDescriptor {
public interface IPluginConfigurer {
// 插件的ID:插件的标识用于区别其它插件[a-z]组成最大32位长度
String getPluginId();
// 插件的名字:最少的概述插件
String getPluginName();
// 即时通信接口
String getIOEventHandler();
// 获得环境变量及默认值
Map<String, String> getEnvironmentVariables();
// 是否是Module(在一级菜单有入口的插件)
boolean isModule();
// 安装插件
public void setup();
}

View File

@ -15,17 +15,85 @@
*/
package com.chatopera.cc.basic.plugins;
import com.chatopera.cc.basic.MainContext;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* 插件注册表
*/
@Component
public class PluginRegistry {
/**
* Plugins Entry
*/
public final static String PLUGIN_CHANNEL_MESSAGER_SUFFIX = "ChannelMessager";
public final static String PLUGIN_ENTRY_SKYPE = "com.chatopera.cc.plugins.skype.PluginDescriptor";
public final static String PLUGIN_ENTRY_CALLOUT = "com.chatopera.cc.plugins.callout.PluginDescriptor";
public final static String PLUGIN_ENTRY_CHATBOT = "com.chatopera.cc.plugins.chatbot.PluginDescriptor";
// 插件列表
private final List<IPluginConfigurer> plugins = new ArrayList<>();
/**
* 添加插件
*
* @param plugin
* @return
*/
public boolean addPlugin(final IPluginConfigurer plugin) {
for (final IPluginConfigurer x : plugins) {
if (StringUtils.equalsIgnoreCase(x.getPluginId(), plugin.getPluginId())) {
return false;
}
}
if (StringUtils.isNotBlank(plugin.getPluginId())) {
MainContext.enableModule(plugin.getPluginId());
}
plugins.add(plugin);
return true;
}
/**
* 获得插件列表
*
* @return
*/
public List<IPluginConfigurer> getPlugins() {
return plugins;
}
/**
* 获得一个插件
*
* @param pluginId
* @return
*/
public Optional<IPluginConfigurer> getPlugin(final String pluginId) {
IPluginConfigurer p = null;
for (final IPluginConfigurer plugin : plugins) {
if (StringUtils.equalsIgnoreCase(plugin.getPluginId(), pluginId)) {
p = plugin;
break;
}
}
return Optional.ofNullable(p);
}
/**
* 删除插件
*
* @param pluginId
*/
public void removePlugin(final String pluginId) {
for (final IPluginConfigurer plugin : plugins) {
if (StringUtils.equalsIgnoreCase(plugin.getPluginId(), pluginId)) {
plugins.remove(plugin);
break;
}
}
}
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (C) 2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.basic.plugins;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* 插架装载器
* TODO Placeholder
*/
public class PluginsLoader {
private final static Logger logger = LoggerFactory.getLogger(PluginsLoader.class);
/**
* 通过插件entry获得PluginName
*
* @param pluginEntry
* @return
*/
public static String getPluginName(final String pluginEntry) {
Class<?> clazz;
try {
clazz = Class.forName(pluginEntry);
IPluginDescriptor clazzInst = (IPluginDescriptor) clazz.newInstance();
Method method = clazz.getMethod("getPluginName");
return (String) method.invoke(clazzInst);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
logger.info("[postConstruct] error", e);
}
return null;
}
/**
* 通过插件entry获得Plugin SocketIO Event Handler
*
* @param pluginEntry
* @return
*/
public static String getIOEventHandler(final String pluginEntry) {
Class<?> clazz;
try {
clazz = Class.forName(pluginEntry);
IPluginDescriptor clazzInst = (IPluginDescriptor) clazz.newInstance();
Method method = clazz.getMethod("getIOEventHandler");
return (String) method.invoke(clazzInst);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
logger.info("[postConstruct] error", e);
}
return null;
}
}

View File

@ -754,24 +754,24 @@ public class Cache {
* Session Config 相关
**************************/
public void putSessionConfigByOrgi(final SessionConfig sessionConfig, final String orgi) {
redisCommand.put(RedisKey.getSessionConfig(orgi), SerializeUtil.serialize(sessionConfig));
public void putSessionConfigByOrgi(final SessionConfig sessionConfig, String organid, final String orgi) {
redisCommand.put(RedisKey.getSessionConfig(organid, orgi), SerializeUtil.serialize(sessionConfig));
}
public SessionConfig findOneSessionConfigByOrgi(final String orgi) {
String serialized = redisCommand.get(RedisKey.getSessionConfig(orgi));
public SessionConfig findOneSessionConfigByOrgi(String organid, final String orgi) {
String serialized = redisCommand.get(RedisKey.getSessionConfig(organid, orgi));
if (StringUtils.isNotBlank(serialized)) {
return (SessionConfig) SerializeUtil.deserialize(serialized);
}
return null;
}
public void deleteSessionConfigByOrgi(final String orgi) {
redisCommand.delete(RedisKey.getSessionConfig(orgi));
public void deleteSessionConfigByOrgi(String organid, final String orgi) {
redisCommand.delete(RedisKey.getSessionConfig(organid, orgi));
}
public boolean existSessionConfigByOrgi(final String orgi) {
return redisCommand.exists(RedisKey.getSessionConfig(orgi));
public boolean existSessionConfigByOrgi(String organid, final String orgi) {
return redisCommand.exists(RedisKey.getSessionConfig(organid, orgi));
}
public void putSessionConfigListByOrgi(final List<SessionConfig> lis, final String orgi) {

View File

@ -238,9 +238,11 @@ public class RedisKey {
return sb.toString();
}
public static String getSessionConfig(final String orgi) {
public static String getSessionConfig(String organid, final String orgi) {
StringBuffer sb = new StringBuffer();
sb.append(orgi);
sb.append(":");
sb.append(organid);
sb.append(":session:config");
return sb.toString();
}

View File

@ -19,6 +19,8 @@ package com.chatopera.cc.config;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.plugins.IPluginConfigurer;
import com.chatopera.cc.basic.plugins.PluginRegistry;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.BlackEntity;
import com.chatopera.cc.model.SysDic;
@ -49,7 +51,6 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
Cache cache = event.getApplicationContext().getBean(Cache.class);
String cacheSetupStrategy = event.getApplicationContext().getEnvironment().getProperty("cache.setup.strategy");
if (!StringUtils.equalsIgnoreCase(cacheSetupStrategy, Constants.cache_setup_strategy_skip)) {
/**************************
@ -58,7 +59,7 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
**************************/
// 首先将之前缓存清空此处使用系统的默认租户信息
cache.eraseSysDicByOrgi(MainContext.SYSTEM_ORGI);
cache.eraseSysDicByOrgi(Constants.SYSTEM_ORGI);
List<SysDic> sysDicList = sysDicRes.findAll();
Map<String, List<SysDic>> rootDictItems = new HashMap<>(); // 关联根词典及其子项
@ -91,19 +92,19 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
// 所以当前代码不支持集群需要解决启动上的这个问题
// 存储根词典 TODO 此处只考虑了系统默认租户
cache.putSysDicByOrgi(new ArrayList<>(rootDics.values()), MainContext.SYSTEM_ORGI);
cache.putSysDicByOrgi(new ArrayList<>(rootDics.values()), Constants.SYSTEM_ORGI);
for (final Map.Entry<String, List<SysDic>> entry : rootDictItems.entrySet()) {
SysDic rootDic = rootDics.get(entry.getKey());
// 打印根词典信息
logger.debug("[onApplicationEvent] root dict: {}, code {}, name {}, item size {}", entry.getKey(), rootDics.get(entry.getKey()).getCode(), rootDics.get(entry.getKey()).getName(), entry.getValue().size());
// 存储子项列表
cache.putSysDicByOrgi(rootDic.getCode(), MainContext.SYSTEM_ORGI, entry.getValue());
cache.putSysDicByOrgi(rootDic.getCode(), Constants.SYSTEM_ORGI, entry.getValue());
// 存储子项成员
cache.putSysDicByOrgi(entry.getValue(), MainContext.SYSTEM_ORGI);
cache.putSysDicByOrgi(entry.getValue(), Constants.SYSTEM_ORGI);
}
List<BlackEntity> blackList = blackListRes.findByOrgi(MainContext.SYSTEM_ORGI);
List<BlackEntity> blackList = blackListRes.findByOrgi(Constants.SYSTEM_ORGI);
for (final BlackEntity black : blackList) {
if (StringUtils.isNotBlank(black.getUserid())) {
if (black.getEndtime() == null || black.getEndtime().after(new Date())) {
@ -116,9 +117,9 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
* 加载系统全局配置
*/
SystemConfigRepository systemConfigRes = event.getApplicationContext().getBean(SystemConfigRepository.class);
SystemConfig config = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
SystemConfig config = systemConfigRes.findByOrgi(Constants.SYSTEM_ORGI);
if (config != null) {
cache.putSystemByIdAndOrgi("systemConfig", MainContext.SYSTEM_ORGI, config);
cache.putSystemByIdAndOrgi("systemConfig", Constants.SYSTEM_ORGI, config);
}
logger.info("[StartedEventListener] setup Sysdicts in Redis done, strategy {}", cacheSetupStrategy);
} else {
@ -129,6 +130,13 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
MainUtils.initSystemSecField(event.getApplicationContext().getBean(TablePropertiesRepository.class));
// MainUtils.initAdv();//初始化广告位
// 初始化插件
PluginRegistry pluginRegistry = MainContext.getContext().getBean(PluginRegistry.class);
for (final IPluginConfigurer p : pluginRegistry.getPlugins()) {
logger.info("[Plugins] registered plugin id {}, class {}", p.getPluginId(), p.getClass().getName());
}
} else {
logger.info("[onApplicationEvent] bypass, initialization has been done already.");
}

View File

@ -16,9 +16,7 @@
*/
package com.chatopera.cc.config;
import com.chatopera.cc.config.plugins.CalloutPluginPresentCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@ -55,29 +53,6 @@ public class ExecutorConfig {
return poolTaskExecutor;
}
/**
* 外呼线程池
* @return
*/
@Conditional(CalloutPluginPresentCondition.class)
@Bean(name = "callOutTaskExecutor")
public ThreadPoolTaskExecutor callout() {
ThreadPoolTaskExecutor poolTaskExecutor = new ThreadPoolTaskExecutor();
// 线程池维护线程的最少数量
poolTaskExecutor.setCorePoolSize(CORE_POOL_SIZE);
// 线程池维护线程的最大数量
poolTaskExecutor.setMaxPoolSize(MAX_POOL_SIZE);
// 线程池所使用的缓冲队列
poolTaskExecutor.setQueueCapacity(200);
// 线程池维护线程所允许的空闲时间
poolTaskExecutor.setKeepAliveSeconds(30000);
poolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
poolTaskExecutor.setThreadNamePrefix("cs-callout-");
return poolTaskExecutor;
}
@Bean(name = "scheduleTaskExecutor")
public ThreadPoolTaskScheduler schedule(){
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2019 Chatopera Inc, All rights reserved.
* <https://www.chatopera.com>
* This software and related documentation are provided under a license agreement containing
* restrictions on use and disclosure and are protected by intellectual property laws.
* Except as expressly permitted in your license agreement or allowed by law, you may not use,
* copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform,
* publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
* or decompilation of this software, unless required by law for interoperability, is prohibited.
*/
package com.chatopera.cc.config.plugins;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Init bean based on conditions
* https://javapapers.com/spring/spring-conditional-annotation/
*/
public class CalloutPluginPresentCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
return MainContext.hasModule(Constants.CSKEFU_MODULE_CALLOUT);
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2019 Chatopera Inc, All rights reserved.
* <https://www.chatopera.com>
* This software and related documentation are provided under a license agreement containing
* restrictions on use and disclosure and are protected by intellectual property laws.
* Except as expressly permitted in your license agreement or allowed by law, you may not use,
* copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform,
* publish, or display any part, in any form, or by any means. Reverse engineering, disassembly,
* or decompilation of this software, unless required by law for interoperability, is prohibited.
*/
package com.chatopera.cc.config.plugins;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Init bean based on conditions
* https://javapapers.com/spring/spring-conditional-annotation/
*/
public class ChatbotPluginPresentCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
return MainContext.hasModule(Constants.CSKEFU_MODULE_CHATBOT);
}
}

View File

@ -1,32 +0,0 @@
/*
* Copyright (C) 2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.config.plugins;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Skype渠道检测
*/
public class SkypePluginPresentCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
return MainContext.hasModule(Constants.CSKEFU_MODULE_SKYPE);
}
}

View File

@ -17,9 +17,16 @@
package com.chatopera.cc.controller;
import com.chatopera.cc.acd.ACDWorkMonitor;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.ExtensionRepository;
import com.chatopera.cc.persistence.repository.OrganRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.proxy.OrganProxy;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,10 +34,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.stream.Collectors;
@Controller
public class ApplicationController extends Handler {
@ -57,19 +71,39 @@ public class ApplicationController extends Handler {
@Value("${tongji.baidu.sitekey}")
private String tongjiBaiduSiteKey;
@Autowired
private OrganProxy organProxy;
@Autowired
private OrganRepository organRepository;
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtensionRepository extensionRes;
@RequestMapping("/")
public ModelAndView admin(HttpServletRequest request) {
// logger.info("[admin] path {} queryString {}", request.getPathInfo(),request.getQueryString());
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/index"));
User logined = super.getUser(request);
Organ currentOrgan = super.getOrgan(request);
TimeZone timezone = TimeZone.getDefault();
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(logined.getOrgi()));
view.addObject("tenant", super.getTenant(request));
view.addObject("istenantshare", super.isEnabletneant());
view.addObject("timeDifference", timezone.getRawOffset());
List<Organ> organs = organProxy.findOrganInIds(logined.getAffiliates());
view.addObject(
"skills",
organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request)).keySet().stream().collect(Collectors.joining(","))
);
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(currentOrgan != null ? currentOrgan.getId() : null, logined.getOrgi()));
view.addObject("istenantshare", false);
view.addObject("timeDifference", timezone.getRawOffset());
view.addObject("organList", organs);
view.addObject("currentOrgan", super.getOrgan(request));
// 增加版本信息
view.addObject("appBuildDate", appBuildDate);
@ -77,19 +111,28 @@ public class ApplicationController extends Handler {
view.addObject("appVersionNumber", appVersionNumber);
view.addObject("appCustomerEntity", appCustomerEntity);
if (super.isEnabletneant()) {
// 多租户启用 非管理员 一定要选择租户才能进入界面
if (!logined.isAdmin() && StringUtils.isNotBlank(
logined.getOrgid()) && super.isTenantconsole() && MainContext.SYSTEM_ORGI.equals(
logined.getOrgi())) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
if (StringUtils.isBlank(logined.getOrgid())) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
}
}
// 在线坐席状态信息
view.addObject("agentStatus", cache.findOneAgentStatusByAgentnoAndOrig(logined.getId(), logined.getOrgi()));
// 呼叫中心信息
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER) && logined.isCallcenter()) {
extensionRes.findByAgentnoAndOrgi(logined.getId(), logined.getOrgi()).ifPresent(ext -> {
pbxHostRes.findById(ext.getHostid()).ifPresent(pbx -> {
Map<String, Object> webrtcData = new HashMap<>();
webrtcData.put("callCenterWebrtcIP", pbx.getWebrtcaddress());
webrtcData.put("callCenterWebRtcPort", pbx.getWebrtcport());
webrtcData.put("callCenterExtensionNum", ext.getExtension());
try {
webrtcData.put("callCenterExtensionPassword", MainUtils.decryption(ext.getPassword()));
} catch (NoSuchAlgorithmException e) {
logger.error("[admin]", e);
webrtcData.put("callCenterError", "Invalid data for callcenter agent.");
}
view.addObject("webrtc", webrtcData);
});
});
}
if (StringUtils.isNotBlank(tongjiBaiduSiteKey) && !StringUtils.equalsIgnoreCase(tongjiBaiduSiteKey, "placeholder")) {
logger.info("tongjiBaiduSiteKey: {}", tongjiBaiduSiteKey);
view.addObject("tongjiBaiduSiteKey", tongjiBaiduSiteKey);
@ -98,9 +141,25 @@ public class ApplicationController extends Handler {
return view;
}
@RequestMapping("/setorgan")
@ResponseBody
public String setOrgan(HttpServletRequest request, @Valid String organ) {
if (StringUtils.isNotBlank(organ)) {
Organ currentOrgan = organRepository.findByIdAndOrgi(organ, super.getOrgi(request));
if (currentOrgan != null) {
request.getSession(true).setAttribute(Constants.ORGAN_SESSION_NAME, currentOrgan);
}
}
return "ok";
}
@RequestMapping("/lazyAgentStatus")
public ModelAndView lazyAgentStatus(HttpServletRequest request) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/index"));
ModelAndView view = request(super.createRequestPageTempletResponse("/public/agentstatustext"));
Organ currentOrgan = super.getOrgan(request);
view.addObject("agentStatusReport", acdWorkMonitor.getAgentReport(currentOrgan != null ? currentOrgan.getId() : null, super.getOrgi(request)));
return view;
}

View File

@ -17,20 +17,18 @@
package com.chatopera.cc.controller;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.Viewport;
import com.chatopera.cc.basic.auth.AuthToken;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.api.QueryParams;
import com.chatopera.cc.exception.CSKefuException;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.StreamingFile;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.Tenant;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.blob.JpaBlobHelper;
import com.chatopera.cc.persistence.repository.StreamingFileRepository;
import com.chatopera.cc.persistence.repository.TenantRepository;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
@ -50,6 +48,7 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
@ -60,9 +59,6 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
public class Handler {
private static final Logger logger = LoggerFactory.getLogger(Handler.class);
@Autowired
private TenantRepository tenantRes;
@Autowired
private JpaBlobHelper jpaBlobHelper;
@ -101,7 +97,7 @@ public class Handler {
user = new User();
user.setId(MainUtils.getContextID(request.getSession().getId()));
user.setUsername(Constants.GUEST_USER + "_" + MainUtils.genIDByKey(user.getId()));
user.setOrgi(MainContext.SYSTEM_ORGI);
user.setOrgi(Constants.SYSTEM_ORGI);
user.setSessionid(user.getId());
}
} else {
@ -110,6 +106,33 @@ public class Handler {
return user;
}
/**
* 获得登录账号的当前导航的组织机构
* @param request
* @return
*/
public Organ getOrgan(HttpServletRequest request) {
User user = getUser(request);
if (user.getOrgans() != null) {
ArrayList<Organ> organs = new ArrayList<>(user.getOrgans().values());
if (organs.size() == 0) {
return null;
}
Organ organ = (Organ) request.getSession(true).getAttribute(Constants.ORGAN_SESSION_NAME);
if (organ == null) {
if (organs.size() > 0) {
organ = organs.get(0);
request.getSession(true).setAttribute(Constants.ORGAN_SESSION_NAME, organ);
}
}
return organ;
} else {
return null;
}
}
/**
* 构建ElasticSearch基于部门查询的Filter
*
@ -310,7 +333,7 @@ public class Handler {
user.setUsername(nickname);
} else {
Map<String, String> sessionMessage = cache.findOneSystemMapByIdAndOrgi(
request.getSession().getId(), MainContext.SYSTEM_ORGI);
request.getSession().getId(), Constants.SYSTEM_ORGI);
if (sessionMessage != null) {
String struname = sessionMessage.get("username");
String strcname = sessionMessage.get("company_name");
@ -340,7 +363,7 @@ public class Handler {
user.setUsername(nickname);
} else {
Map<String, String> sessionMessage = cache.findOneSystemMapByIdAndOrgi(
sessionid, MainContext.SYSTEM_ORGI);
sessionid, Constants.SYSTEM_ORGI);
if (sessionMessage != null) {
String struname = sessionMessage.get("username");
String strcname = sessionMessage.get("company_name");
@ -455,68 +478,13 @@ public class Handler {
return pagesize;
}
public String getOrgi() {
return Constants.SYSTEM_ORGI;
}
// FIXME: 保存此处是为了兼容之前到代码宜去掉
public String getOrgi(HttpServletRequest request) {
return getUser(request).getOrgi();
}
/**
* 机构id
*
* @param request
* @return
*/
public String getOrgid(HttpServletRequest request) {
User u = getUser(request);
return u.getOrgid();
}
public Tenant getTenant(HttpServletRequest request) {
return tenantRes.findById(getOrgi(request));
}
/**
* 根据是否租户共享获取orgi
*
* @param request
* @return
*/
public String getOrgiByTenantshare(HttpServletRequest request) {
SystemConfig systemConfig = MainUtils.getSystemConfig();
if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantshare()) {
User user = this.getUser(request);
return user.getOrgid();
}
return getOrgi(request);
}
/**
* 判断是否租户共享
*
* @return
*/
public boolean isTenantshare() {
SystemConfig systemConfig = MainUtils.getSystemConfig();
return systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantshare();
}
/**
* 判断是否多租户
*
* @return
*/
public boolean isEnabletneant() {
SystemConfig systemConfig = MainUtils.getSystemConfig();
return systemConfig != null && systemConfig.isEnabletneant();
}
/**
* 判断是否多租户
*
* @return
*/
public boolean isTenantconsole() {
SystemConfig systemConfig = MainUtils.getSystemConfig();
return systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantconsole();
return getOrgi();
}
public long getStarttime() {

View File

@ -21,17 +21,14 @@ import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.basic.auth.AuthToken;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.UserRole;
import com.chatopera.cc.persistence.repository.AgentStatusRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.proxy.AgentProxy;
import com.chatopera.cc.proxy.AgentSessionProxy;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
@ -73,12 +70,6 @@ public class LoginController extends Handler {
@Autowired
private AuthToken authToken;
@Autowired
private AgentStatusRepository agentStatusRes;
@Autowired
private Cache cache;
@Autowired
private AgentProxy agentProxy;
@ -161,7 +152,7 @@ public class LoginController extends Handler {
view.addObject("tongjiBaiduSiteKey", tongjiBaiduSiteKey);
}
if(StringUtils.isNotBlank(adsLoginBanner) && StringUtils.equalsIgnoreCase(adsLoginBanner, "on")){
if (StringUtils.isNotBlank(adsLoginBanner) && StringUtils.equalsIgnoreCase(adsLoginBanner, "on")) {
view.addObject("adsLoginBanner", "on");
}
@ -309,10 +300,6 @@ public class LoginController extends Handler {
}
super.setUser(request, loginUser);
// 当前用户 企业id为空 调到创建企业页面
if (StringUtils.isBlank(loginUser.getOrgid())) {
view = new ModelAndView("redirect:/apps/organization/add.html");
}
}
return view;
}
@ -378,21 +365,10 @@ public class LoginController extends Handler {
if (StringUtils.isNotBlank(user.getPassword())) {
user.setPassword(MainUtils.md5(user.getPassword()));
}
user.setOrgi(super.getOrgiByTenantshare(request));
/*if(StringUtils.isNotBlank(super.getUser(request).getOrgid())) {
user.setOrgid(super.getUser(request).getOrgid());
}else {
user.setOrgid(MainContext.SYSTEM_ORGI);
}*/
user.setOrgi(super.getOrgi());
userRepository.save(user);
OnlineUserProxy.clean(super.getOrgi(request));
}
ModelAndView view = this.processLogin(request, user, "");
//当前用户 企业id为空 调到创建企业页面
if (StringUtils.isBlank(user.getOrgid())) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/organization/add.html"));
}
return view;
}

View File

@ -79,7 +79,7 @@ public class AdminController extends Handler {
map.put("onlineUserCache", cache.getOnlineUserSizeByOrgi(orgi));
map.put("onlineUserClients", OnlineUserProxy.webIMClients.size());
map.put("chatClients", NettyClients.getInstance().size());
map.put("systemCaches", cache.getSystemSizeByOrgi(MainContext.SYSTEM_ORGI));
map.put("systemCaches", cache.getSystemSizeByOrgi(Constants.SYSTEM_ORGI));
map.put("agentReport", acdWorkMonitor.getAgentReport(orgi));
map.put("webIMReport", MainUtils.getWebIMReport(userEventRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainUtils.getStartTime(), MainUtils.getEndTime())));
@ -107,12 +107,7 @@ public class AdminController extends Handler {
private List<User> getAgent(HttpServletRequest request) {
//获取当前产品or租户坐席数
List<User> userList = new ArrayList<>();
if (super.isEnabletneant()) {
userList = userRes.findByOrgidAndAgentAndDatastatus(super.getOrgid(request), true, false);
} else {
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
}
List<User> userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
return userList.isEmpty() ? new ArrayList<User>() : userList;
}

View File

@ -86,8 +86,7 @@ public class OrganController extends Handler {
@RequestMapping("/index")
@Menu(type = "admin", subtype = "organ")
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String organ, @Valid String msg) {
List<Organ> organList = organRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request), super.getOrgid(request));
List<Organ> organList = organRepository.findByOrgi(super.getOrgi());
map.addAttribute("organList", organList);
if (organList.size() > 0) {
Organ organData = null;
@ -105,15 +104,12 @@ public class OrganController extends Handler {
map.addAttribute(
"userList", userProxy.findByOrganAndOrgiAndDatastatus(
organData.getId(),
super.getOrgiByTenantshare(request),
super.getOrgi(),
false));
}
}
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
map.addAttribute(
"roleList", roleRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request),
super.getOrgid(request)));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
map.addAttribute("roleList", roleRepository.findByOrgi(super.getOrgi()));
map.put("msg", msg);
return request(super.createAdminTempletResponse("/admin/organ/index"));
}
@ -121,18 +117,15 @@ public class OrganController extends Handler {
@RequestMapping("/add")
@Menu(type = "admin", subtype = "organ")
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String parent, @Valid String area) {
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
if (!StringUtils.isBlank(parent)) {
map.addAttribute("organ", organRepository.findByIdAndOrgi(parent, super.getOrgiByTenantshare(request)));
map.addAttribute("organ", organRepository.findByIdAndOrgi(parent, super.getOrgi()));
}
if (!StringUtils.isBlank(area)) {
map.addAttribute("area", areaRepository.findByIdAndOrgi(area, super.getOrgiByTenantshare(request)));
map.addAttribute("area", areaRepository.findByIdAndOrgi(area, super.getOrgi()));
}
map.addAttribute(
"organList", organRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request),
super.getOrgid(request)));
map.addAttribute("organList", organRepository.findByOrgi(super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/organ/add"));
}
@ -140,25 +133,16 @@ public class OrganController extends Handler {
@RequestMapping("/save")
@Menu(type = "admin", subtype = "organ")
public ModelAndView save(HttpServletRequest request, @Valid Organ organ) {
Organ tempOrgan = organRepository.findByNameAndOrgiAndOrgid(
organ.getName(), super.getOrgiByTenantshare(request), super.getOrgid(request));
Organ tempOrgan = organRepository.findByNameAndOrgi(organ.getName(), super.getOrgi(request));
String msg = "admin_organ_new_success";
String firstId = null;
if (tempOrgan != null) {
msg = "admin_organ_update_name_not"; //分类名字重复
} else {
organ.setOrgi(super.getOrgiByTenantshare(request));
if (!StringUtils.isBlank(super.getUser(request).getOrgid())) {
organ.setOrgid(super.getUser(request).getOrgid());
} else {
organ.setOrgid(MainContext.SYSTEM_ORGI);
}
organ.setOrgi(super.getOrgi());
firstId = organ.getId();
organRepository.save(organ);
OnlineUserProxy.clean(super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse(
"redirect:/admin/organ/index.html?msg=" + msg + "&organ=" + firstId));
@ -176,11 +160,10 @@ public class OrganController extends Handler {
@Menu(type = "admin", subtype = "seluser", admin = true)
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String organ) {
map.addAttribute(
"userList", userRepository.findByOrgiAndDatastatusAndOrgid(super.getOrgiByTenantshare(request), false,
super.getOrgid(request)));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
"userList", userRepository.findByOrgiAndDatastatus(super.getOrgi(), false));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgi());
map.addAttribute("userOrganList", userProxy
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgiByTenantshare(request), false));
.findByOrganAndOrgiAndDatastatus(organ, super.getOrgi(), false));
map.addAttribute("organ", organData);
return request(super.createRequestPageTempletResponse("/admin/organ/seluser"));
}
@ -200,13 +183,13 @@ public class OrganController extends Handler {
HttpServletRequest request,
final @Valid String[] users,
final @Valid String organ
) {
) {
logger.info("[saveuser] save users {} into organ {}", StringUtils.join(users, ","), organ);
final User loginUser = super.getUser(request);
if (users != null && users.length > 0) {
List<String> chosen = new ArrayList<String>(Arrays.asList(users));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgiByTenantshare(request));
Organ organData = organRepository.findByIdAndOrgi(organ, super.getOrgi());
List<User> organUserList = userRepository.findAll(chosen);
for (final User user : organUserList) {
OrganUser ou = organUserRes.findByUseridAndOrgan(user.getId(), organ);
@ -240,19 +223,18 @@ public class OrganController extends Handler {
* 以下更新技能组状态
*/
AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
user.getId(), super.getOrgiByTenantshare(request));
user.getId(), super.getOrgi());
// TODO 因为一个用户可以包含在多个技能组中所以skill应该对应
// 一个List列表此处需要重构Skill为列表
if (agentStatus != null) {
userProxy.attachOrgansPropertiesForUser(user);
agentStatus.setSkills(user.getSkills());
cache.putAgentStatusByOrgi(agentStatus, super.getOrgiByTenantshare(request));
cache.putAgentStatusByOrgi(agentStatus, super.getOrgi());
}
}
}
userRepository.save(organUserList);
OnlineUserProxy.clean(super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
@ -264,11 +246,10 @@ public class OrganController extends Handler {
final HttpServletRequest request,
final @Valid String id,
final @Valid String organ
) {
) {
logger.info("[userroledelete] user id {}, organ {}", id, organ);
if (id != null) {
organUserRes.deleteOrganUserByUseridAndOrgan(id, organ);
OnlineUserProxy.clean(super.getOrgi(request));
}
return request(super.createRequestPageTempletResponse("redirect:/admin/organ/index.html?organ=" + organ));
}
@ -277,13 +258,10 @@ public class OrganController extends Handler {
@Menu(type = "admin", subtype = "organ")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/organ/edit"));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgiByTenantshare(request)));
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
map.addAttribute("areaList", areaRepository.findByOrgi(super.getOrgi()));
view.addObject("organData", organRepository.findByIdAndOrgi(id, super.getOrgi()));
map.addAttribute(
"organList", organRepository.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request),
super.getOrgid(request)));
map.addAttribute("organList", organRepository.findByOrgi(super.getOrgi()));
return view;
}
@ -306,7 +284,7 @@ public class OrganController extends Handler {
}
map.addAttribute("cacheList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_AREA_DIC));
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
map.addAttribute("organData", organRepository.findByIdAndOrgi(id, super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/organ/area"));
}
@ -314,12 +292,11 @@ public class OrganController extends Handler {
@RequestMapping("/area/update")
@Menu(type = "admin", subtype = "organ")
public ModelAndView areaupdate(HttpServletRequest request, @Valid Organ organ) {
Organ tempOrgan = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
Organ tempOrgan = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgi());
String msg = "admin_organ_update_success";
if (tempOrgan != null) {
tempOrgan.setArea(organ.getArea());
organRepository.save(tempOrgan);
OnlineUserProxy.clean(super.getOrgi(request));
} else {
msg = "admin_organ_update_not_exist";
}
@ -332,7 +309,7 @@ public class OrganController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid Organ organ) {
String msg = "admin_organ_delete";
Organ organSelf = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgiByTenantshare(request));
Organ organSelf = organRepository.findByIdAndOrgi(organ.getId(), super.getOrgi());
List<Organ> organParentAre = organRepository.findByOrgiAndParent(organSelf.getOrgi(), organSelf.getId());
if (organ != null && organParentAre != null && organParentAre.size() > 0) {
msg = "admin_oran_not_delete";
@ -340,7 +317,6 @@ public class OrganController extends Handler {
List<OrganUser> organUsers = organUserRes.findByOrgan(organ.getId());
organUserRes.deleteInBatch(organUsers);
organRepository.delete(organ);
OnlineUserProxy.clean(super.getOrgi(request));
} else {
msg = "admin_organ_not_exist";
}
@ -350,8 +326,8 @@ public class OrganController extends Handler {
@RequestMapping("/auth/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request));
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(super.getOrgiByTenantshare(request), organData);
Organ organData = organRepository.findByIdAndOrgi(id, super.getOrgi());
List<OrganRole> organRoleList = organRoleRes.findByOrgiAndOrgan(super.getOrgi(), organData);
organRoleRes.delete(organRoleList);
if (!StringUtils.isBlank(menus)) {
String[] menusarray = menus.split(",");
@ -364,7 +340,7 @@ public class OrganController extends Handler {
organRole.setOrgan(organData);
organRole.setCreater(super.getUser(request).getId());
organRole.setOrgi(super.getOrgiByTenantshare(request));
organRole.setOrgi(super.getOrgi(request));
organRole.setCreatetime(new Date());
organRoleRes.save(organRole);
}

View File

@ -61,7 +61,7 @@ public class RoleController extends Handler {
@RequestMapping("/index")
@Menu(type = "admin", subtype = "role")
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String role, @Valid String msg) {
List<Role> roleList = roleRepository.findByOrgiAndOrgid(super.getOrgiByTenantshare(request), super.getOrgid(request));
List<Role> roleList = roleRepository.findByOrgi(super.getOrgi());
map.addAttribute("roleList", roleList);
map.addAttribute("msg", msg);
if (roleList.size() > 0) {
@ -77,7 +77,7 @@ public class RoleController extends Handler {
map.addAttribute("roleData", roleData = roleList.get(0));
}
if (roleData != null) {
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), roleData, new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData, new PageRequest(super.getP(request), super.getPs(request))));
}
}
return request(super.createAdminTempletResponse("/admin/role/index"));
@ -92,22 +92,15 @@ public class RoleController extends Handler {
@RequestMapping("/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView save(HttpServletRequest request, @Valid Role role) {
Role tempRole = roleRepository.findByNameAndOrgiAndOrgid(role.getName(), super.getOrgiByTenantshare(request), super.getOrgid(request));
Role tempRole = roleRepository.findByNameAndOrgi(role.getName(), super.getOrgi());
String msg = "admin_role_save_success";
if (tempRole != null) {
msg = "admin_role_save_exist";
} else {
role.setOrgi(super.getOrgiByTenantshare(request));
role.setOrgi(super.getOrgi());
role.setCreater(super.getUser(request).getId());
role.setCreatetime(new Date());
role.setUpdatetime(new Date());
if (StringUtils.isNotBlank(super.getUser(request).getOrgid())) {
role.setOrgid(super.getUser(request).getOrgid());
} else {
role.setOrgid(MainContext.SYSTEM_ORGI);
}
roleRepository.save(role);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?msg=" + msg));
@ -116,9 +109,9 @@ public class RoleController extends Handler {
@RequestMapping("/seluser")
@Menu(type = "admin", subtype = "seluser", admin = true)
public ModelAndView seluser(ModelMap map, HttpServletRequest request, @Valid String role) {
map.addAttribute("userList", userRepository.findByOrgiAndDatastatusAndOrgid(super.getOrgiByTenantshare(request), false, super.getOrgid(request)));
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgiByTenantshare(request));
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), roleData));
map.addAttribute("userList", userRepository.findByOrgiAndDatastatus(super.getOrgi(), false));
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgi());
map.addAttribute("userRoleList", userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData));
map.addAttribute("role", roleData);
return request(super.createRequestPageTempletResponse("/admin/role/seluser"));
}
@ -127,8 +120,8 @@ public class RoleController extends Handler {
@RequestMapping("/saveuser")
@Menu(type = "admin", subtype = "saveuser", admin = true)
public ModelAndView saveuser(HttpServletRequest request, @Valid String[] users, @Valid String role) {
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgiByTenantshare(request));
List<UserRole> userRoleList = userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), roleData);
Role roleData = roleRepository.findByIdAndOrgi(role, super.getOrgi());
List<UserRole> userRoleList = userRoleRes.findByOrgiAndRole(super.getOrgi(), roleData);
if (users != null && users.length > 0) {
for (String user : users) {
boolean exist = false;
@ -142,7 +135,7 @@ public class RoleController extends Handler {
UserRole userRole = new UserRole();
userRole.setUser(new User(user));
userRole.setRole(new Role(role));
userRole.setOrgi(super.getOrgiByTenantshare(request));
userRole.setOrgi(super.getOrgi());
userRole.setCreater(super.getUser(request).getId());
userRoleRes.save(userRole);
}
@ -164,27 +157,20 @@ public class RoleController extends Handler {
@Menu(type = "admin", subtype = "role")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/role/edit"));
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
view.addObject("roleData", roleRepository.findByIdAndOrgi(id, super.getOrgi()));
return view;
}
@RequestMapping("/update")
@Menu(type = "admin", subtype = "role")
public ModelAndView update(HttpServletRequest request, @Valid Role role) {
Role tempRoleExist = roleRepository.findByNameAndOrgi(role.getName(), super.getOrgiByTenantshare(request));
Role tempRoleExist = roleRepository.findByNameAndOrgi(role.getName(), super.getOrgi());
String msg = "";
if (tempRoleExist == null) {
msg = "admin_role_update_success";
Role tempRole = roleRepository.findByIdAndOrgi(role.getId(), super.getOrgiByTenantshare(request));
Role tempRole = roleRepository.findByIdAndOrgi(role.getId(), super.getOrgi());
tempRole.setName(role.getName());
tempRole.setUpdatetime(new Date());
if (StringUtils.isNotBlank(super.getUser(request).getOrgid())) {
tempRole.setOrgid(super.getUser(request).getOrgid());
} else {
tempRole.setOrgid(MainContext.SYSTEM_ORGI);
}
roleRepository.save(tempRole);
} else if (!role.getId().equals(tempRoleExist.getId())) {
msg = "admin_role_update_not_exist";
@ -197,7 +183,7 @@ public class RoleController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid Role role) {
String msg = "admin_role_delete";
if (role != null) {
userRoleRes.delete(userRoleRes.findByOrgiAndRole(super.getOrgiByTenantshare(request), role));
userRoleRes.delete(userRoleRes.findByOrgiAndRole(super.getOrgi(), role));
roleRepository.delete(role);
} else {
msg = "admin_role_not_exist";
@ -214,18 +200,18 @@ public class RoleController extends Handler {
map.addAttribute("resourceList", sysDicRes.findByDicid(sysDic.getId()));
}
map.addAttribute("sysDic", sysDic);
Role role = roleRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request));
Role role = roleRepository.findByIdAndOrgi(id, super.getOrgi());
map.addAttribute("role", role);
map.addAttribute("roleAuthList", roleAuthRes.findByRoleidAndOrgi(role.getId(), super.getOrgiByTenantshare(request)));
map.addAttribute("roleAuthList", roleAuthRes.findByRoleidAndOrgi(role.getId(), super.getOrgi()));
return request(super.createRequestPageTempletResponse("/admin/role/auth"));
}
@RequestMapping("/auth/save")
@Menu(type = "admin", subtype = "role")
public ModelAndView authsave(HttpServletRequest request, @Valid String id, @Valid String menus) {
logger.info("[authsave] id {}, menus {}", id, menus);
// logger.info("[authsave] id {}, menus {}", id, menus);
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleidAndOrgi(id, super.getOrgiByTenantshare(request));
List<RoleAuth> roleAuthList = roleAuthRes.findByRoleidAndOrgi(id, super.getOrgi());
roleAuthRes.delete(roleAuthList);
if (StringUtils.isNotBlank(menus)) {
String[] menuarray = menus.split(",");
@ -242,7 +228,7 @@ public class RoleController extends Handler {
if (sysDic != null && (!StringUtils.equals(sysDic.getParentid(), "0"))) {
logger.debug("[authsave] get sysdict {}, code {}, name {}, parent {}", sysDic.getId(), sysDic.getCode(), sysDic.getName(), sysDic.getParentid());
roleAuth.setCreater(super.getUser(request).getId());
roleAuth.setOrgi(super.getOrgiByTenantshare(request));
roleAuth.setOrgi(super.getOrgi());
roleAuth.setCreatetime(new Date());
roleAuth.setName(sysDic.getName());
roleAuth.setDicvalue(sysDic.getCode());
@ -253,4 +239,4 @@ public class RoleController extends Handler {
}
return request(super.createRequestPageTempletResponse("redirect:/admin/role/index.html?role=" + id));
}
}
}

View File

@ -16,12 +16,17 @@
*/
package com.chatopera.cc.controller.admin;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.OrganUser;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.UserRole;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,6 +42,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author 程序猿DD
@ -54,24 +60,49 @@ public class UsersController extends Handler {
@Autowired
private UserRoleRepository userRoleRes;
@Autowired
OrganProxy organProxy;
@Autowired
UserProxy userProxy;
@Autowired
private OrganUserRepository organUserRes;
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtensionRepository extensionRes;
@RequestMapping("/index")
@Menu(type = "admin", subtype = "user")
public ModelAndView index(ModelMap map, HttpServletRequest request) throws IOException {
map.addAttribute(
"userList",
userRepository.findByDatastatusAndOrgiAndOrgidAndSuperadminNot(
false,
super.getOrgiByTenantshare(request),
super.getOrgid(request),
true,
new PageRequest(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
"createtime"
)
)
);
User logined = super.getUser(request);
if (!logined.isSuperadmin()) {
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
map.addAttribute("userList", userProxy.findUserInOrgans(organs.keySet(), new PageRequest(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
"createtime"
)));
} else {
map.addAttribute(
"userList",
userRepository.findByDatastatusAndOrgiAndSuperadminNot(
false,
super.getOrgi(),
true,
new PageRequest(
super.getP(request),
super.getPs(request),
Sort.Direction.ASC,
"createtime"
)
)
);
}
return request(super.createAdminTempletResponse("/admin/user/index"));
}
@ -85,7 +116,20 @@ public class UsersController extends Handler {
@Menu(type = "admin", subtype = "user")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
ModelAndView view = request(super.createRequestPageTempletResponse("/admin/user/edit"));
view.addObject("userData", userRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request)));
User user = userRepository.findById(id);
if (user != null && MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
// 加载呼叫中心信息
extensionRes.findByAgentnoAndOrgi(user.getId(), user.getOrgi()).ifPresent(p -> {
user.setExtensionId(p.getId());
user.setExtension(p);
pbxHostRes.findById(p.getHostid()).ifPresent(b -> {
user.setPbxhostId(b.getId());
user.setPbxHost(b);
});
});
}
view.addObject("userData", user);
return view;
}
@ -94,12 +138,19 @@ public class UsersController extends Handler {
public ModelAndView delete(HttpServletRequest request, @Valid User user) {
String msg = "admin_user_delete";
if (user != null) {
List<UserRole> userRole = userRoleRes.findByOrgiAndUser(super.getOrgiByTenantshare(request), user);
userRoleRes.delete(userRole); //删除用户的时候同时删除用户对应的
user = userRepository.getOne(user.getId());
user.setDatastatus(true);
userRepository.save(user);
OnlineUserProxy.clean(super.getOrgi(request));
User dbUser = userRepository.getOne(user.getId());
if (dbUser.isSuperadmin()) {
msg = "admin_user_abandoned";
} else {
// 删除用户的时候同时删除用户对应的权限数据
List<UserRole> userRole = userRoleRes.findByOrgiAndUser(super.getOrgi(), user);
userRoleRes.delete(userRole);
// 删除用户对应的组织机构关系
List<OrganUser> organUsers = organUserRes.findByUserid(user.getId());
organUserRes.delete(organUsers);
userRepository.delete(dbUser);
}
} else {
msg = "admin_user_not_exist";
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Acl;
import com.chatopera.cc.persistence.repository.AclRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterAclController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private AclRepository aclRes ;
@RequestMapping(value = "/acl")
@Menu(type = "callcenter" , subtype = "callcenteracl" , access = false , admin = true)
public ModelAndView acl(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("aclList" , aclRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/index"));
}
@RequestMapping(value = "/acl/add")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acladd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/add"));
}
@RequestMapping(value = "/acl/save")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView aclsave(ModelMap map , HttpServletRequest request , @Valid Acl acl) {
if(!StringUtils.isBlank(acl.getName())){
int count = aclRes.countByNameAndOrgi(acl.getName(), super.getOrgi(request)) ;
if(count == 0){
acl.setOrgi(super.getOrgi(request));
acl.setCreater(super.getUser(request).getId());
aclRes.save(acl) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+acl.getHostid()));
}
@RequestMapping(value = "/acl/edit")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acledit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("acl" , aclRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/acl/edit"));
}
@RequestMapping(value = "/acl/update")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Acl acl) {
if(!StringUtils.isBlank(acl.getId())){
Acl oldAcl = aclRes.findByIdAndOrgi(acl.getId(), super.getOrgi(request)) ;
if(oldAcl!=null){
oldAcl.setName(acl.getName());
oldAcl.setDefaultvalue(acl.getDefaultvalue());
oldAcl.setStrategy(acl.getStrategy());
aclRes.save(oldAcl);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+acl.getHostid()));
}
@RequestMapping(value = "/acl/delete")
@Menu(type = "callcenter" , subtype = "acl" , access = false , admin = true)
public ModelAndView acldelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
aclRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/acl.html?hostid="+hostid));
}
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.BlackEntity;
import com.chatopera.cc.persistence.repository.BlackListRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterBlackController extends Handler{
@Autowired
private BlackListRepository blackRes ;
@RequestMapping(value = "/black")
@Menu(type = "callcenter" , subtype = "callcenterblack" , access = false , admin = true)
public ModelAndView black(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.addAttribute("blackList" , blackRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/index"));
}
@RequestMapping(value = "/black/add")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blackadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/add"));
}
@RequestMapping(value = "/black/save")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blacksave(ModelMap map , HttpServletRequest request , @Valid String phones) {
if(!StringUtils.isBlank(phones)){
String[] ps = phones.split("[ ,\t\n]") ;
for(String ph : ps){
if(ph.length() >= 3){
int count = blackRes.countByPhoneAndOrgi(ph.trim(), super.getOrgi(request)) ;
if(count == 0){
BlackEntity be = new BlackEntity();
be.setPhone(ph.trim());
be.setChannel(MainContext.ChannelType.PHONE.toString());
be.setOrgi(super.getOrgi(request));
be.setCreater(super.getUser(request).getId());
blackRes.save(be) ;
}
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
}
@RequestMapping(value = "/black/edit")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blackedit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("black" , blackRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/black/edit"));
}
@RequestMapping(value = "/black/update")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid BlackEntity black) {
if(!StringUtils.isBlank(black.getId())){
BlackEntity oldBlack = blackRes.findByIdAndOrgi(black.getId(), super.getOrgi(request)) ;
if(oldBlack!=null){
oldBlack.setPhone(black.getPhone());
oldBlack.setChannel(MainContext.ChannelType.PHONE.toString());
oldBlack.setOrgi(super.getOrgi(request));
blackRes.save(oldBlack);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
}
@RequestMapping(value = "/black/delete")
@Menu(type = "callcenter" , subtype = "black" , access = false , admin = true)
public ModelAndView blackdelete(ModelMap map , HttpServletRequest request , @Valid String id) {
if(!StringUtils.isBlank(id)){
blackRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/black.html"));
}
}

View File

@ -1,173 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.persistence.interfaces.CallCenterInterface;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@RequestMapping(value = "/index")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String msg) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
for (PbxHost pbxHost : pbxHostList) {
if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
}
}
}
map.addAttribute("pbxHostList", pbxHostList);
return request(super.createAdminTempletResponse("/admin/callcenter/index"));
}
@RequestMapping(value = "/pbxhost")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhost(ModelMap map, HttpServletRequest request) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean("callcenter");
for (PbxHost pbxHost : pbxHostList) {
if (callCenterImpl != null) {
pbxHost.setConnected(callCenterImpl.connected(pbxHost.getId()));
}
}
}
map.addAttribute("pbxHostList", pbxHostList);
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/index"));
}
@RequestMapping(value = "/pbxhost/add")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostadd(ModelMap map, HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/add"));
}
@RequestMapping(value = "/pbxhost/save")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostsave(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null;
if (!StringUtils.isBlank(pbxHost.getName())) {
int count = pbxHostRes.countByHostnameAndOrgi(pbxHost.getHostname(), super.getOrgi(request));
if (count == 0) {
pbxHost.setOrgi(super.getOrgi(request));
pbxHost.setCreater(super.getUser(request).getId());
pbxHostRes.save(pbxHost);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
if (callCenterImpl != null) {
try {
callCenterImpl.init(pbxHost);
} catch (Exception ex) {
msg = ex.getMessage();
ex.printStackTrace();
}
}
}
}
}
if (!StringUtils.isBlank(msg)) {
view = request(
super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg));
}
return view;
}
@RequestMapping(value = "/pbxhost/edit")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/pbxhost/edit"));
}
@RequestMapping(value = "/pbxhost/update")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
String msg = null;
if (!StringUtils.isBlank(pbxHost.getId())) {
PbxHost destHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
destHost.setHostname(pbxHost.getHostname());
destHost.setIpaddr(pbxHost.getIpaddr());
destHost.setName(pbxHost.getName());
destHost.setPort(pbxHost.getPort());
if (!StringUtils.isBlank(pbxHost.getPassword())) {
destHost.setPassword(pbxHost.getPassword());
}
pbxHostRes.save(destHost);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
if (callCenterImpl != null) {
try {
callCenterImpl.init(destHost);
} catch (Exception ex) {
msg = ex.getMessage();
ex.printStackTrace();
}
}
}
}
if (!StringUtils.isBlank(msg)) {
view = request(
super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html?msg=" + msg));
}
return view;
}
@RequestMapping(value = "/pbxhost/delete")
@Menu(type = "callcenter", subtype = "pbxhost", access = false, admin = true)
public ModelAndView mediadelete(ModelMap map, HttpServletRequest request, @Valid String id) {
if (!StringUtils.isBlank(id)) {
pbxHostRes.delete(id);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
if (callCenterImpl != null) {
callCenterImpl.remove(id);
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/pbxhost.html"));
}
}

View File

@ -1,248 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.CallcenterOutboundProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.freeswitch.model.CallCenterAgent;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterExtentionController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private SipTrunkRepository sipTrunkRes;
@Autowired
private MediaRepository mediaRes;
@Autowired
private ServiceAiRepository serviceAiRes;
@Autowired
private ProductRepository productRes;
@Autowired
private QueSurveyProcessRepository queSurveyProcessRes;
@Autowired
private Cache cache;
@RequestMapping(value = "/extention")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView extention(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList", extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/index"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
PbxHost pbxHost = pbxHostList.get(0);
if (StringUtils.isNotBlank(hostid)) {
for (PbxHost pbx : pbxHostList) {
if (pbx.getId().equals(hostid)) {
pbxHost = pbx;
break;
}
}
}
return pbxHost;
}
@RequestMapping(value = "/extention/add")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/add"));
}
@RequestMapping(value = "/extention/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getExtention()) && StringUtils.isNotBlank(extention.getPassword())) {
String[] extstr = extention.getExtention().split("[, ]");
int extnum = 0;
for (String ext : extstr) {
if (ext.matches("[\\d]{3,8}")) { //分机号码最少3位数字
createNewExtention(ext, super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
} else {
String[] ph = ext.split("[~-]");
if (ph.length == 2 && ph[0].matches("[\\d]{3,8}") && ph[1].matches("[\\d]{3,8}") && ph[0].length() == ph[1].length()) {
int start = Integer.parseInt(ph[0]);
int end = Integer.parseInt(ph[1]);
for (int i = start; i <= end && extnum < 100; i++) { //最大一次批量生产的 分机号不超过100个
createNewExtention(String.valueOf(i), super.getUser(request), extention.getHostid(), extention.getPassword(), super.getOrgi(request), extention);
}
}
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
private Extention createNewExtention(String num, User user, String hostid, String password, String orgi, Extention src) {
Extention extno = new Extention();
extno.setExtention(num);
extno.setOrgi(orgi);
extno.setCreater(user.getId());
extno.setHostid(hostid);
extno.setPassword(password);
extno.setPlaynum(src.isPlaynum());
extno.setCallout(src.isCallout());
extno.setRecord(src.isRecord());
extno.setExtype(src.getExtype());
extno.setMediapath(src.getMediapath());
extno.setSiptrunk(src.getSiptrunk());
extno.setEnablewebrtc(src.isEnablewebrtc());
int count = extentionRes.countByExtentionAndHostidAndOrgi(extno.getExtention(), hostid, orgi);
if (count == 0) {
extentionRes.save(extno);
}
return extno;
}
@RequestMapping(value = "/extention/edit")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/edit"));
}
@RequestMapping(value = "/extention/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionupdate(ModelMap map, HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null) {
// ext.setExtention(extention.getExtention());//分机号不能修改
if (StringUtils.isNotBlank(extention.getPassword())) {
ext.setPassword(extention.getPassword());
}
ext.setPlaynum(extention.isPlaynum());
ext.setCallout(extention.isCallout());
ext.setRecord(extention.isRecord());
ext.setExtype(extention.getExtype());
ext.setSubtype(extention.getSubtype());
ext.setDescription(extention.getDescription());
ext.setMediapath(extention.getMediapath());
ext.setSiptrunk(extention.getSiptrunk());
ext.setEnablewebrtc(extention.isEnablewebrtc());
ext.setUpdatetime(new Date());
extentionRes.save(ext);
List<CallCenterAgent> callOutAgentList = CallcenterOutboundProxy.extention(ext.getExtention());
for (CallCenterAgent callOutAgent : callOutAgentList) {
callOutAgent.setSiptrunk(ext.getSiptrunk());
cache.putCallCenterAgentByIdAndOrgi(callOutAgent.getUserid(), callOutAgent.getOrgi(), callOutAgent);
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
@RequestMapping(value = "/extention/ivr")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView ivr(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("extention", extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.put("mediaList", mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
map.put("queList", queSurveyProcessRes.findByOrgi(super.getOrgi(request)));
map.put("productList", productRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/extention/ivr"));
}
@RequestMapping(value = "/extention/ivr/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView ivrupdate(ModelMap map, HttpServletRequest request, @Valid Extention extention) {
if (StringUtils.isNotBlank(extention.getId())) {
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request));
if (ext != null) {
ext.setEnableai(extention.getEnableai());
ext.setAiid(extention.getAiid());
ext.setSceneid(extention.getSceneid());
ext.setWelcomemsg(extention.getWelcomemsg());
ext.setWaitmsg(extention.getWaitmsg());
ext.setTipmessage(extention.getTipmessage());
ext.setAitype(extention.getAitype());
ext.setBustype(extention.getBustype());
ext.setProid(extention.getProid());
ext.setQueid(extention.getQueid());
extentionRes.save(ext);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + extention.getHostid()));
}
@RequestMapping(value = "/extention/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentiondelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
if (StringUtils.isNotBlank(id)) {
extentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/extention.html?hostid=" + hostid));
}
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.IvrMenuRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterIvrController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private ExtentionRepository extentionRes ;
@Autowired
private IvrMenuRepository ivrMenuRes;
@RequestMapping(value = "/ivr")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView ivr(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("ivrList" , extentionRes.findByExtypeAndOrgi("ivr", super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/index"));
}
@RequestMapping(value = "/ivr/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/edit"));
}
@RequestMapping(value = "/ivr/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) {
if(!StringUtils.isBlank(extention.getId())){
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)) ;
ext.setExtention(extention.getExtention());
ext.setDescription(extention.getDescription());
extentionRes.save(ext) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid="+extention.getHostid()));
}
@RequestMapping(value = "/ivr/delete")
@Menu(type = "callcenter" , subtype = "ivr" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
extentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/ivr.html?hostid="+hostid));
}
@RequestMapping(value = "/ivr/design")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView design(ModelMap map , HttpServletRequest request , @Valid String hostid , @Valid String id) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.addAttribute("ivrMenuList" , ivrMenuRes.findByExtentionidAndHostidAndOrgi(id, hostid, super.getOrgi(request)));
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/design"));
}
@RequestMapping(value = "/ivr/menu/add")
@Menu(type = "callcenter" , subtype = "callcenterivr" , access = false , admin = true)
public ModelAndView ivrmenuadd(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid , @Valid String parentid) {
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/ivr/menuadd"));
}
}

View File

@ -1,158 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Media;
import com.chatopera.cc.persistence.repository.MediaRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterMediaController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private MediaRepository mediaRes ;
@Value("${web.upload-path}")
private String path;
@RequestMapping(value = "/media")
@Menu(type = "callcenter" , subtype = "callcentermedia" , access = false , admin = true)
public ModelAndView media(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("mediaList" , mediaRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/index"));
}
@RequestMapping(value = "/media/add")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediaadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/add"));
}
@RequestMapping(value = "/media/save")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediasave(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media();
media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid"));
if(!StringUtils.isBlank(media.getName())){
int count = mediaRes.countByNameAndOrgi(media.getName(), super.getOrgi(request)) ;
if(count == 0){
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ;
media.setOrgi(super.getOrgi(request));
media.setCreater(super.getUser(request).getId());
media.setFilelength((int) mediafile.getSize());
media.setContent(mediafile.getContentType());
media.setFilename(fileName);
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){
File logoDir = new File(path , "media");
if(!logoDir.exists()){
logoDir.mkdirs() ;
}
FileCopyUtils.copy(mediafile.getBytes(), new File(path , fileName));
}
mediaRes.save(media) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+media.getHostid()));
}
@RequestMapping(value = "/media/edit")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediaedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("media" , mediaRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/edit"));
}
@RequestMapping(value = "/media/update")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @RequestParam(value = "mediafile", required = false) MultipartFile mediafile) throws IOException {
Media media = new Media();
media.setName(request.getParameter("name"));
media.setHostid(request.getParameter("hostid"));
media.setId(request.getParameter("id"));
if(!StringUtils.isBlank(media.getId())){
Media oldMedia = mediaRes.findByIdAndOrgi(media.getId(), super.getOrgi(request)) ;
if(oldMedia!=null){
if(mediafile!=null && mediafile.getSize() > 0){
File wavFile = new File(path , oldMedia.getFilename());
if(!wavFile.exists()){
wavFile.deleteOnExit();
}
String fileName = "media/"+ MainUtils.getUUID()+mediafile.getOriginalFilename().substring(mediafile.getOriginalFilename().lastIndexOf(".")) ;
oldMedia.setFilename(fileName);
if(mediafile!=null && mediafile.getOriginalFilename().lastIndexOf(".") > 0){
File mediaDir = new File(path , "media");
if(!mediaDir.exists()){
mediaDir.mkdirs() ;
}
FileCopyUtils.copy(mediafile.getBytes(), new File(path , fileName));
}
}
oldMedia.setName(media.getName());
mediaRes.save(oldMedia);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+media.getHostid()));
}
@RequestMapping(value = "/media/delete")
@Menu(type = "callcenter" , subtype = "media" , access = false , admin = true)
public ModelAndView mediadelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
mediaRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/media.html?hostid="+hostid));
}
@RequestMapping(value = "/play")
@Menu(type = "callcenter" , subtype = "play" , access = false)
public ModelAndView play(ModelMap map , HttpServletRequest request ,@Valid final String id ,@Valid final String hostid) {
map.addAttribute("media", mediaRes.findByIdAndOrgi(id, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/media/play"));
}
}

View File

@ -1,133 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.persistence.interfaces.CallCenterInterface;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.ServiceAiRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterResourceController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private ServiceAiRepository serviceAiRes;
@RequestMapping(value = "/resource")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request)));
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList",
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createAdminTempletResponse("/admin/callcenter/resource/index"));
}
@RequestMapping(value = "/resource/config")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView config(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList",
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/resource/config"));
}
@RequestMapping(value = "/resource/save")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid PbxHost pbxHost) throws Exception {
PbxHost tempPbxHost = pbxHostRes.findByIdAndOrgi(pbxHost.getId(), super.getOrgi(request));
if (tempPbxHost != null) {
pbxHost.setCreater(tempPbxHost.getCreater());
pbxHost.setCreatetime(tempPbxHost.getCreatetime());
if (StringUtils.isBlank(pbxHost.getPassword())) {
pbxHost.setPassword(tempPbxHost.getPassword());
}
pbxHost.setOrgi(super.getOrgi(request));
pbxHostRes.save(pbxHost);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
CallCenterInterface callCenterImpl = (CallCenterInterface) MainContext.getContext().getBean(
"callcenter");
callCenterImpl.init(pbxHost);
}
}
return request(super.createRequestPageTempletResponse(
"redirect:/admin/callcenter/resource.html?hostid=" + pbxHost.getId()));
}
@RequestMapping(value = "/resource/pbxhost")
@Menu(type = "callcenter", subtype = "callcenter", access = false, admin = true)
public ModelAndView resourcepbx(ModelMap map, HttpServletRequest request, @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request));
map.addAttribute("pbxHostList", pbxHostList);
PbxHost pbxHost = null;
if (pbxHostList.size() > 0) {
map.addAttribute("pbxHost", pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("extentionList",
extentionRes.findByHostidAndOrgi(pbxHost.getId(), super.getOrgi(request)));
}
return request(super.createAdminTempletResponse("/admin/callcenter/resource/pbxhost"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList, String hostid) {
PbxHost pbxHost = pbxHostList.get(0);
if (!StringUtils.isBlank(hostid)) {
for (PbxHost pbx : pbxHostList) {
if (pbx.getId().equals(hostid)) {
pbxHost = pbx;
break;
}
}
}
return pbxHost;
}
}

View File

@ -1,135 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.RouterRules;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.RouterRulesRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterRouterController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private RouterRulesRepository routerRulesRes ;
@RequestMapping(value = "/router")
@Menu(type = "callcenter" , subtype = "callcenterresource" , access = false , admin = true)
public ModelAndView skill(ModelMap map , HttpServletRequest request , @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)) ;
map.addAttribute("pbxHostList" , pbxHostList);
if(pbxHostList.size() > 0){
map.addAttribute("pbxHost" , pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("routerRulesList" , routerRulesRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/index"));
}
@RequestMapping(value = "/router/add")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/add"));
}
@RequestMapping(value = "/router/save")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid RouterRules router) {
if(!StringUtils.isBlank(router.getName())){
int count = routerRulesRes.countByNameAndOrgi(router.getName(), super.getOrgi(request)) ;
if(count == 0){
router.setOrgi(super.getOrgi(request));
router.setCreater(super.getUser(request).getId());
routerRulesRes.save(router) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid()));
}
@RequestMapping(value = "/router/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView routeredit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("routerRules" , routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/edit"));
}
@RequestMapping(value = "/router/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) {
if(!StringUtils.isBlank(router.getId())){
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)) ;
if(oldRouter!=null){
oldRouter.setName(router.getName());
oldRouter.setField(router.getField());
oldRouter.setRegex(router.getRegex());
oldRouter.setRouterinx(router.getRouterinx());
oldRouter.setFalsebreak(router.isFalsebreak());
routerRulesRes.save(oldRouter);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid()));
}
@RequestMapping(value = "/router/code")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView routercode(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("routerRules" , routerRulesRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/peer/code"));
}
@RequestMapping(value = "/router/code/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView routercodeupdate(ModelMap map , HttpServletRequest request , @Valid RouterRules router) {
if(!StringUtils.isBlank(router.getId())){
RouterRules oldRouter = routerRulesRes.findByIdAndOrgi(router.getId(), super.getOrgi(request)) ;
if(!StringUtils.isBlank(router.getRoutercontent())){
oldRouter.setRoutercontent(router.getRoutercontent());
routerRulesRes.save(oldRouter);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+router.getHostid()));
}
@RequestMapping(value = "/router/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
routerRulesRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/peer.html?hostid="+hostid));
}
}

View File

@ -1,152 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.SipTrunk;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.SipTrunkRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterSipTrunkController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private SipTrunkRepository sipTrunkRes;
@Autowired
private Cache cache;
@RequestMapping(value = "/siptrunk")
@Menu(type = "callcenter", subtype = "callcenterresource", access = false, admin = true)
public ModelAndView skill(ModelMap map, HttpServletRequest request, @Valid String hostid) {
if (!StringUtils.isBlank(hostid)) {
map.addAttribute("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
map.addAttribute("sipTrunkListList", sipTrunkRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/index"));
}
@RequestMapping(value = "/siptrunk/add")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionadd(ModelMap map, HttpServletRequest request, @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/add"));
}
@RequestMapping(value = "/siptrunk/save")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentionsave(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getName())) {
int count = sipTrunkRes.countByNameAndOrgi(siptrunk.getName(), super.getOrgi(request));
if (count == 0) {
siptrunk.setOrgi(super.getOrgi(request));
siptrunk.setCreater(super.getUser(request).getId());
sipTrunkRes.save(siptrunk);
cache.putSystemByIdAndOrgi(siptrunk.getId(), siptrunk.getOrgi(), siptrunk);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
}
@RequestMapping(value = "/siptrunk/edit")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/edit"));
}
@RequestMapping(value = "/siptrunk/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView pbxhostupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getId())) {
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
if (oldSipTrunk != null) {
oldSipTrunk.setName(siptrunk.getName());
oldSipTrunk.setSipserver(siptrunk.getSipserver());
oldSipTrunk.setPort(siptrunk.getPort());
oldSipTrunk.setProtocol(siptrunk.getProtocol());
oldSipTrunk.setRegister(siptrunk.isRegister());
oldSipTrunk.setDefaultsip(siptrunk.isDefaultsip());
oldSipTrunk.setTitle(siptrunk.getTitle());
oldSipTrunk.setEnablecallagent(siptrunk.isEnablecallagent());
oldSipTrunk.setOutnumber(siptrunk.getOutnumber());
oldSipTrunk.setBusyext(siptrunk.getBusyext());
oldSipTrunk.setNotready(siptrunk.getNotready());
oldSipTrunk.setNoname(siptrunk.getNoname());
oldSipTrunk.setProvince(siptrunk.getProvince());
oldSipTrunk.setCity(siptrunk.getCity());
oldSipTrunk.setPrefix(siptrunk.getPrefix());
sipTrunkRes.save(oldSipTrunk);
cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
}
@RequestMapping(value = "/siptrunk/code")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcode(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
map.addAttribute("siptrunk", sipTrunkRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/callcenter/siptrunk/code"));
}
@RequestMapping(value = "/siptrunk/code/update")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView siptrunkcodeupdate(ModelMap map, HttpServletRequest request, @Valid SipTrunk siptrunk) {
if (!StringUtils.isBlank(siptrunk.getId())) {
SipTrunk oldSipTrunk = sipTrunkRes.findByIdAndOrgi(siptrunk.getId(), super.getOrgi(request));
if (!StringUtils.isBlank(siptrunk.getSipcontent())) {
oldSipTrunk.setSipcontent(siptrunk.getSipcontent());
sipTrunkRes.save(oldSipTrunk);
cache.putSystemByIdAndOrgi(oldSipTrunk.getId(), oldSipTrunk.getOrgi(), oldSipTrunk);
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + siptrunk.getHostid()));
}
@RequestMapping(value = "/siptrunk/delete")
@Menu(type = "callcenter", subtype = "extention", access = false, admin = true)
public ModelAndView extentiondelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String hostid) {
if (!StringUtils.isBlank(id)) {
sipTrunkRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/siptrunk.html?hostid=" + hostid));
}
}

View File

@ -1,186 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.admin.callcenter;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CallCenterSkill;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.SkillExtention;
import com.chatopera.cc.persistence.repository.CallCenterSkillRepository;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.PbxHostRepository;
import com.chatopera.cc.persistence.repository.SkillExtentionRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/admin/callcenter")
public class CallCenterSkillController extends Handler {
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private CallCenterSkillRepository skillRes ;
@Autowired
private SkillExtentionRepository skillExtentionRes;
@RequestMapping(value = "/skill")
@Menu(type = "callcenter" , subtype = "callcenterresource" , access = false , admin = true)
public ModelAndView skill(ModelMap map , HttpServletRequest request , @Valid String hostid) {
List<PbxHost> pbxHostList = pbxHostRes.findByOrgi(super.getOrgi(request)) ;
map.addAttribute("pbxHostList" , pbxHostList);
PbxHost pbxHost = null ;
if(pbxHostList.size() > 0){
map.addAttribute("pbxHost" , pbxHost = getPbxHost(pbxHostList, hostid));
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("skillExtentionList" , skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/index"));
}
private PbxHost getPbxHost(List<PbxHost> pbxHostList ,String hostid){
PbxHost pbxHost = pbxHostList.get(0) ;
if(!StringUtils.isBlank(hostid)){
for(PbxHost pbx : pbxHostList){
if(pbx.getId().equals(hostid)){
pbxHost = pbx; break ;
}
}
}
return pbxHost ;
}
@RequestMapping(value = "/skill/add")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionadd(ModelMap map , HttpServletRequest request , @Valid String hostid) {
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/add"));
}
@RequestMapping(value = "/skill/save")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionsave(ModelMap map , HttpServletRequest request , @Valid CallCenterSkill skill) {
if(!StringUtils.isBlank(skill.getSkill())){
int count = skillRes.countBySkillAndOrgi(skill.getSkill(), super.getOrgi(request)) ;
if(count == 0){
skill.setOrgi(super.getOrgi(request));
skill.setCreater(super.getUser(request).getId());
skillRes.save(skill) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+skill.getHostid()));
}
@RequestMapping(value = "/skill/edit")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentionedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
map.addAttribute("extention" , extentionRes.findByIdAndOrgi(id, super.getOrgi(request)));
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/edit"));
}
@RequestMapping(value = "/skill/update")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView pbxhostupdate(ModelMap map , HttpServletRequest request , @Valid Extention extention) {
if(!StringUtils.isBlank(extention.getId())){
Extention ext = extentionRes.findByIdAndOrgi(extention.getId(), super.getOrgi(request)) ;
if(ext!=null && !StringUtils.isBlank(ext.getExtention()) && ext.getExtention().matches("[\\d]{3,8}")){
ext.setExtention(extention.getExtention());
if(!StringUtils.isBlank(extention.getPassword())){
ext.setPassword(extention.getPassword());
}
ext.setUpdatetime(new Date());
extentionRes.save(ext) ;
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+extention.getHostid()));
}
@RequestMapping(value = "/skill/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView extentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
extentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid));
}
@RequestMapping(value = "/skill/imp")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillimp(ModelMap map , HttpServletRequest request , @Valid String hostid) {
if(!StringUtils.isBlank(hostid)){
map.put("pbxHost", pbxHostRes.findByIdAndOrgi(hostid, super.getOrgi(request))) ;
map.put("extentionList", extentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request))) ;
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(hostid , super.getOrgi(request)));
}
return request(super.createRequestPageTempletResponse("/admin/callcenter/skill/imp"));
}
@RequestMapping(value = "/skill/extention/delete")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillextentiondelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String hostid) {
if(!StringUtils.isBlank(id)){
skillExtentionRes.delete(id);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid));
}
@RequestMapping(value = "/skill/extention/save")
@Menu(type = "callcenter" , subtype = "extention" , access = false , admin = true)
public ModelAndView skillextentionsave(ModelMap map , HttpServletRequest request , @Valid SkillExtention skillExtention, @Valid String hostid , @Valid String[] exts) {
if(exts!=null && exts.length > 0){
List<SkillExtention> skillExtentionList = skillExtentionRes.findByHostidAndOrgi(hostid, super.getOrgi(request)) ;
for(String ext :exts){
SkillExtention skillExt = new SkillExtention() ;
skillExt.setOrgi(super.getOrgi(request));
skillExt.setCreater(super.getUser(request).getId());
skillExt.setCreatetime(new Date());
skillExt.setExtention(ext);
skillExt.setHostid(hostid);
skillExt.setSkillid(skillExtention.getSkillid());
skillExt.setUpdatetime(new Date());
boolean ingroup = false;
for(SkillExtention temp : skillExtentionList){
if(temp.getSkillid().equals(skillExt.getSkillid()) && temp.getExtention().equals(skillExt.getExtention())){
ingroup = true ;
}
}
if(ingroup == false){
skillExtentionRes.save(skillExt) ;
}
}
}
return request(super.createRequestPageTempletResponse("redirect:/admin/callcenter/skill.html?hostid="+hostid));
}
}

View File

@ -19,13 +19,11 @@ package com.chatopera.cc.controller.admin.channel;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.CousultInvite;
import com.chatopera.cc.model.SNSAccount;
import com.chatopera.cc.model.Secret;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.ConsultInviteRepository;
import com.chatopera.cc.persistence.repository.SNSAccountRepository;
import com.chatopera.cc.persistence.repository.SecretRepository;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Base62;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
@ -42,9 +40,9 @@ import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
*
*/
@Controller
@ -60,11 +58,20 @@ public class SNSAccountIMController extends Handler {
@Autowired
private SecretRepository secRes;
@Autowired
private OrganProxy organProxy;
@RequestMapping("/index")
@Menu(type = "admin", subtype = "im", access = false, admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute,@RequestParam(name = "status",required = false) String status ) {
map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgi(MainContext.ChannelType.WEBIM.toString(), super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
map.addAttribute("status",status);
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute, @RequestParam(name = "status", required = false) String status) {
User logined = super.getUser(request);
if (logined.isSuperadmin()) {
map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgi(MainContext.ChannelType.WEBIM.toString(), super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
} else {
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
map.addAttribute("snsAccountList", snsAccountRes.findBySnstypeAndOrgiAndOrgan(MainContext.ChannelType.WEBIM.toString(), super.getOrgi(request), organs.keySet(), new PageRequest(super.getP(request), super.getPs(request))));
}
map.addAttribute("status", status);
List<Secret> secretConfig = secRes.findByOrgi(super.getOrgi(request));
if (secretConfig != null && secretConfig.size() > 0) {
map.addAttribute("secret", secretConfig.get(0));

View File

@ -291,21 +291,10 @@ public class WebIMController extends Handler {
*/
private List<Organ> getSkillGroups(HttpServletRequest request) {
List<Organ> skillgroups = new ArrayList<>();
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
skillgroups = organRes.findAll(organIdList);
} else {
List<Organ> allgroups = organRes.findByOrgiAndOrgid(super.getOrgi(request), super.getOrgid(request));
for (Organ o : allgroups) {
if (o.isSkill()) {
skillgroups.add(o);
}
List<Organ> allgroups = organRes.findByOrgi(super.getOrgi(request));
for (Organ o : allgroups) {
if (o.isSkill()) {
skillgroups.add(o);
}
}
return skillgroups;
@ -318,19 +307,7 @@ public class WebIMController extends Handler {
* @return
*/
private List<User> getUsers(HttpServletRequest request) {
List<User> userList;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
userList = userProxy.findByOrganInAndAgentAndDatastatus(organIdList, true, false);
} else {
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
}
List<User> userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
return userList;
}
}

View File

@ -194,8 +194,8 @@ public class SystemConfigController extends Handler {
@Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException {
/*SystemConfig systemConfig = systemConfigRes.findByOrgi(super.getOrgi(request)) ;
config.setOrgi(super.getOrgi(request));*/
SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI);
config.setOrgi(MainContext.SYSTEM_ORGI);
SystemConfig systemConfig = systemConfigRes.findByOrgi(Constants.SYSTEM_ORGI);
config.setOrgi(Constants.SYSTEM_ORGI);
String msg = "0";
if (StringUtils.isBlank(config.getJkspassword())) {
config.setJkspassword(null);

View File

@ -20,11 +20,14 @@ import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Dict;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.SystemMessage;
import com.chatopera.cc.persistence.repository.OrganRepository;
import com.chatopera.cc.persistence.repository.SystemMessageRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -35,135 +38,148 @@ import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
@Controller
@RequestMapping("/admin")
public class SystemMessageController extends Handler {
@Autowired
private SystemMessageRepository systemMessageRepository;
@Autowired
private SystemMessageRepository systemMessageRepository;
@Autowired
private OrganRepository organRes;
@RequestMapping("/email/index")
@Menu(type = "setting" , subtype = "email")
public ModelAndView index(ModelMap map , HttpServletRequest request) throws IOException {
map.addAttribute("emailList", systemMessageRepository.findByMsgtypeAndOrgi("email" , super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/email/index"));
@Menu(type = "setting", subtype = "email")
public ModelAndView index(ModelMap map, HttpServletRequest request) throws IOException {
Page<SystemMessage> emails = systemMessageRepository.findByMsgtypeAndOrgi("email", super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)));
List<Organ> organs = organRes.findByOrgi(super.getOrgi(request));
emails.getContent().stream().forEach(p -> {
organs.stream().filter(o -> StringUtils.equals(p.getOrgan(), o.getId())).findAny().ifPresent(o -> p.setOrgan(o.getName()));
});
map.addAttribute("emailList", emails);
return request(super.createAdminTempletResponse("/admin/email/index"));
}
@RequestMapping("/email/add")
@Menu(type = "admin" , subtype = "email")
public ModelAndView add(ModelMap map , HttpServletRequest request) {
@Menu(type = "admin", subtype = "email")
public ModelAndView add(ModelMap map, HttpServletRequest request) {
map.put("organList", organRes.findByOrgi(super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/email/add"));
}
@RequestMapping("/email/save")
@Menu(type = "admin" , subtype = "user")
public ModelAndView save(HttpServletRequest request ,@Valid SystemMessage email) throws NoSuchAlgorithmException {
email.setOrgi(super.getOrgi(request));
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if(!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}
systemMessageRepository.save(email) ;
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
@Menu(type = "admin", subtype = "user")
public ModelAndView save(HttpServletRequest request, @Valid SystemMessage email) throws NoSuchAlgorithmException {
email.setOrgi(super.getOrgi(request));
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if (!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}
systemMessageRepository.save(email);
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
}
@RequestMapping("/email/edit")
@Menu(type = "admin" , subtype = "email")
public ModelAndView edit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("email", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request))) ;
@Menu(type = "admin", subtype = "email")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.put("organList", organRes.findByOrgi(super.getOrgi(request)));
map.addAttribute("email", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/email/edit"));
}
@RequestMapping("/email/update")
@Menu(type = "admin" , subtype = "user" , admin = true)
public ModelAndView update(HttpServletRequest request ,@Valid SystemMessage email) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request)) ;
if(email!=null) {
email.setCreatetime(temp.getCreatetime());
email.setOrgi(temp.getOrgi());
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if(!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
}else {
email.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(email) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
@Menu(type = "admin", subtype = "user", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid SystemMessage email) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request));
if (email != null) {
email.setCreatetime(temp.getCreatetime());
email.setOrgi(temp.getOrgi());
email.setMsgtype(MainContext.SystemMessageType.EMAIL.toString());
if (!StringUtils.isBlank(email.getSmtppassword())) {
email.setSmtppassword(MainUtils.encryption(email.getSmtppassword()));
} else {
email.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(email);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
}
@RequestMapping("/email/delete")
@Menu(type = "admin" , subtype = "user")
public ModelAndView delete(HttpServletRequest request ,@Valid SystemMessage email) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request)) ;
if(email!=null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
@Menu(type = "admin", subtype = "user")
public ModelAndView delete(HttpServletRequest request, @Valid SystemMessage email) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(email.getId(), super.getOrgi(request));
if (email != null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/email/index.html"));
}
@RequestMapping("/sms/index")
@Menu(type = "setting" , subtype = "sms")
public ModelAndView smsindex(ModelMap map , HttpServletRequest request) throws IOException {
map.addAttribute("smsList", systemMessageRepository.findByMsgtypeAndOrgi("sms" , super.getOrgi(request) , new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/sms/index"));
@Menu(type = "setting", subtype = "sms")
public ModelAndView smsindex(ModelMap map, HttpServletRequest request) throws IOException {
map.addAttribute("smsList", systemMessageRepository.findByMsgtypeAndOrgi("sms", super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request))));
return request(super.createAdminTempletResponse("/admin/sms/index"));
}
@RequestMapping("/sms/add")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smsadd(ModelMap map , HttpServletRequest request) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type")) ;
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsadd(ModelMap map, HttpServletRequest request) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type"));
return request(super.createRequestPageTempletResponse("/admin/sms/add"));
}
@RequestMapping("/sms/save")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smssave(HttpServletRequest request ,@Valid SystemMessage sms) throws NoSuchAlgorithmException {
sms.setOrgi(super.getOrgi(request));
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if(!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}
systemMessageRepository.save(sms) ;
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
@Menu(type = "admin", subtype = "sms")
public ModelAndView smssave(HttpServletRequest request, @Valid SystemMessage sms) throws NoSuchAlgorithmException {
sms.setOrgi(super.getOrgi(request));
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if (!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}
systemMessageRepository.save(sms);
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
}
@RequestMapping("/sms/edit")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smsedit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type")) ;
map.addAttribute("sms", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request))) ;
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsedit(ModelMap map, HttpServletRequest request, @Valid String id) {
map.addAttribute("smsType", Dict.getInstance().getDic("com.dic.sms.type"));
map.addAttribute("sms", systemMessageRepository.findByIdAndOrgi(id, super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/admin/sms/edit"));
}
@RequestMapping("/sms/update")
@Menu(type = "admin" , subtype = "sms" , admin = true)
public ModelAndView smsupdate(HttpServletRequest request ,@Valid SystemMessage sms) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request)) ;
if(sms!=null) {
sms.setCreatetime(temp.getCreatetime());
sms.setOrgi(temp.getOrgi());
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if(!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
}else {
sms.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(sms) ;
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
@Menu(type = "admin", subtype = "sms", admin = true)
public ModelAndView smsupdate(HttpServletRequest request, @Valid SystemMessage sms) throws NoSuchAlgorithmException {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request));
if (sms != null) {
sms.setCreatetime(temp.getCreatetime());
sms.setOrgi(temp.getOrgi());
sms.setMsgtype(MainContext.SystemMessageType.SMS.toString());
if (!StringUtils.isBlank(sms.getSmtppassword())) {
sms.setSmtppassword(MainUtils.encryption(sms.getSmtppassword()));
} else {
sms.setSmtppassword(temp.getSmtppassword());
}
systemMessageRepository.save(sms);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
}
@RequestMapping("/sms/delete")
@Menu(type = "admin" , subtype = "sms")
public ModelAndView smsdelete(HttpServletRequest request ,@Valid SystemMessage sms) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request)) ;
if(sms!=null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
@Menu(type = "admin", subtype = "sms")
public ModelAndView smsdelete(HttpServletRequest request, @Valid SystemMessage sms) {
SystemMessage temp = systemMessageRepository.findByIdAndOrgi(sms.getId(), super.getOrgi(request));
if (sms != null) {
systemMessageRepository.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/admin/sms/index.html"));
}
}

View File

@ -67,7 +67,7 @@ public class TemplateController extends Handler{
@Menu(type = "admin" , subtype = "template" , access = false , admin = true)
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response) throws Exception {
List<Template> templateList = templateRes.findByOrgi(super.getOrgi(request)) ;
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Template-Export-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".data");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Template-Export-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".data");
response.getOutputStream().write(MainUtils.toBytes(templateList));
return ;
}

View File

@ -313,7 +313,7 @@ public class ApiContactNotesController extends Handler {
JsonObject json = new JsonObject();
HttpHeaders headers = RestUtils.header();
j.addProperty("creater", super.getUser(request).getId());
j.addProperty("orgi", MainContext.SYSTEM_ORGI);
j.addProperty("orgi", Constants.SYSTEM_ORGI);
if (!j.has("ops")) {
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);

View File

@ -16,6 +16,7 @@
package com.chatopera.cc.controller.api;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.controller.api.request.RestUtils;
@ -197,7 +198,7 @@ public class ApiContactTagsController extends Handler {
JsonObject json = new JsonObject();
HttpHeaders headers = RestUtils.header();
j.addProperty("creater", super.getUser(request).getId());
j.addProperty("orgi", MainContext.SYSTEM_ORGI);
j.addProperty("orgi", super.getOrgi(request));
if (!j.has("ops")) {
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);

View File

@ -104,10 +104,10 @@ public class ApiServiceQueneController extends Handler {
p.setAgentno(logined.getId());
p.setLogindate(new Date());
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(logined.getOrgi());
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(logined.getOrgi());
p.setUpdatetime(new Date());
p.setOrgi(super.getOrgi(request));
p.setMaxusers(sessionConfig.getMaxuser());
// p.setMaxusers(sessionConfig.getMaxuser());
return p;
});

View File

@ -16,16 +16,16 @@
*/
package com.chatopera.cc.controller.api;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.controller.api.request.RestUtils;
import com.chatopera.cc.model.AgentStatus;
import com.chatopera.cc.model.OrganUser;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.OrganUserRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.UserRoleRepository;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
@ -61,16 +61,19 @@ public class ApiUserController extends Handler {
private final static Logger logger = LoggerFactory.getLogger(ApiUserController.class);
@Autowired
private UserRepository userRes;
@Autowired
private OrganUserRepository organUserRepository;
private Cache cache;
@Autowired
private UserProxy userProxy;
@Autowired
private Cache cache;
private UserRepository userRes;
@Autowired
private OrganUserRepository organUserRes;
@Autowired
private UserRoleRepository userRoleRes;
/**
* 返回用户列表支持分页分页参数为 p=1&ps=50默认分页尺寸为 20条每页
@ -83,11 +86,11 @@ public class ApiUserController extends Handler {
@Menu(type = "apps", subtype = "user", access = true)
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String id, @Valid String username) {
Page<User> userList = null;
if (!StringUtils.isBlank(id)) {
if (StringUtils.isNotBlank(id)) {
userList = userRes.findByIdAndOrgi(
id, super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request)));
} else {
if (!StringUtils.isBlank(username)) {
if (StringUtils.isNotBlank(username)) {
userList = userRes.findByDatastatusAndOrgiAndUsernameLike(
false, super.getOrgi(request), username, new PageRequest(
super.getP(request),
@ -100,52 +103,6 @@ public class ApiUserController extends Handler {
return new ResponseEntity<>(new RestResult(RestResultType.OK, userList), HttpStatus.OK);
}
/**
* 新增或修改用户用户 在修改用户信息的时候如果用户 密码未改变请设置为 NULL
*
* @param request
* @param user
* @return
*/
@RequestMapping(method = RequestMethod.PUT)
@Menu(type = "apps", subtype = "user", access = true)
public ResponseEntity<RestResult> put(HttpServletRequest request, @Valid User user) {
if (user != null && !StringUtils.isBlank(user.getUsername())) {
if (!StringUtils.isBlank(user.getPassword())) {
user.setPassword(MainUtils.md5(user.getPassword()));
userRes.save(user);
} else if (!StringUtils.isBlank(user.getId())) {
User old = userRes.findByIdAndOrgi(user.getId(), super.getOrgi(request));
user.setPassword(old.getPassword());
userRes.save(user);
}
}
return new ResponseEntity<>(new RestResult(RestResultType.OK), HttpStatus.OK);
}
/**
* 删除用户只提供 按照用户ID删除 并且不能删除系统管理员
*
* @param request
* @param id
* @return
*/
@RequestMapping(method = RequestMethod.DELETE)
@Menu(type = "apps", subtype = "user", access = true)
public ResponseEntity<RestResult> delete(HttpServletRequest request, @Valid String id) {
RestResult result = new RestResult(RestResultType.OK);
User user = null;
if (!StringUtils.isBlank(id)) {
user = userRes.findByIdAndOrgi(id, super.getOrgi(request));
if (!user.isSuperadmin()) { //系统管理员 不允许 使用 接口删除
userRes.delete(user);
} else {
result.setStatus(RestResultType.USER_DELETE);
}
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
/**
* 用户管理
*
@ -177,6 +134,9 @@ public class ApiUserController extends Handler {
case "findbyorgan":
json = findByOrgan(j);
break;
case "delete":
json = delete(request, j);
break;
default:
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的操作。");
@ -184,37 +144,24 @@ public class ApiUserController extends Handler {
}
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
}
/**
* 根据组织查找用户
* 创建新用户
*
* @param request
* @param payload
* @return
*/
private JsonObject findByOrgan(final JsonObject payload) {
final JsonObject resp = new JsonObject();
if (payload.has("organ")) {
List<OrganUser> organUsers = organUserRepository.findByOrgan(payload.get("organ").getAsString());
List<String> userids = organUsers.stream().map(p -> p.getUserid()).collect(Collectors.toList());
List<User> users = userRes.findAll(userids);
JsonArray data = new JsonArray();
users.stream().forEach(u -> {
JsonObject obj = new JsonObject();
obj.addProperty("id", u.getId());
obj.addProperty("uname", u.getUname());
data.add(obj);
});
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.add(RestUtils.RESP_KEY_DATA, data);
} else {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Invalid params.");
}
private JsonObject create(final HttpServletRequest request, final JsonObject payload) {
logger.info("[create] payload {}", payload.toString());
// 创建新用户时阻止传入ID
payload.remove("id");
// 从payload中创建User
User user = userProxy.parseUserFromJson(payload);
JsonObject resp = userProxy.createNewUser(user);
logger.info("[create] response {}", resp.toString());
return resp;
}
@ -235,7 +182,7 @@ public class ApiUserController extends Handler {
return resp;
}
final User previous = userRes.getOne(updated.getId());
final User previous = userRes.findById(updated.getId());
if (previous != null) {
String msg = userProxy.validUserUpdate(updated, previous);
if (StringUtils.equals(msg, "edit_user_success")) {
@ -260,17 +207,16 @@ public class ApiUserController extends Handler {
previous.setUsername(updated.getUsername());
previous.setEmail(updated.getEmail());
previous.setMobile(updated.getMobile());
previous.setSipaccount(updated.getSipaccount());
previous.setAgent(updated.isAgent());
previous.setOrgi(super.getOrgiByTenantshare(request));
if (StringUtils.isNotBlank(previous.getOrgid())) {
previous.setOrgid(previous.getOrgid());
} else {
previous.setOrgid(MainContext.SYSTEM_ORGI);
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CALLCENTER)) {
previous.setCallcenter(updated.isCallcenter());
if (updated.isCallcenter()) {
previous.setExtensionId(updated.getExtensionId());
previous.setPbxhostId(updated.getPbxhostId());
}
}
previous.setCallcenter(updated.isCallcenter());
if (StringUtils.isNotBlank(updated.getPassword())) {
previous.setPassword(MainUtils.md5(updated.getPassword()));
}
@ -283,7 +229,6 @@ public class ApiUserController extends Handler {
previous.setAdmin(updated.isAdmin());
previous.setSuperadmin(false);
userRes.save(previous);
OnlineUserProxy.clean(previous.getOrgi());
}
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
@ -298,34 +243,80 @@ public class ApiUserController extends Handler {
}
/**
* 创建新用户
* 根据组织查找用户
*
* @param request
* @param payload
* @return
*/
private JsonObject create(final HttpServletRequest request, final JsonObject payload) {
logger.info("[create] payload {}", payload.toString());
final User logined = super.getUser(request);
JsonObject resp = new JsonObject();
private JsonObject findByOrgan(final JsonObject payload) {
final JsonObject resp = new JsonObject();
if (payload.has("organ")) {
List<OrganUser> organUsers = organUserRes.findByOrgan(payload.get("organ").getAsString());
List<String> userids = organUsers.stream().map(p -> p.getUserid()).collect(Collectors.toList());
List<User> users = userRes.findAll(userids);
// 从payload中创建User
User newUser = null;
// 创建新用户时阻止传入ID
payload.remove("id");
newUser = userProxy.parseUserFromJson(payload);
final String msg = userProxy.createNewUser(
newUser, logined.getOrgi(), logined.getOrgid(), super.getOrgiByTenantshare(request));
JsonArray data = new JsonArray();
users.stream().forEach(u -> {
JsonObject obj = new JsonObject();
obj.addProperty("id", u.getId());
obj.addProperty("uname", u.getUname());
data.add(obj);
});
if (StringUtils.isNotBlank(msg)) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_DATA, msg);
resp.add(RestUtils.RESP_KEY_DATA, data);
} else {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Unexpected response.");
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Invalid params.");
}
return resp;
}
/**
* 删除账号
*
* @param request
* @param payload
* @return
*/
private JsonObject delete(final HttpServletRequest request, final JsonObject payload) {
logger.info("[create] payload {}", payload.toString());
JsonObject resp = new JsonObject();
if (payload.has("id")) {
String id = payload.get("id").getAsString();
if (StringUtils.isNotBlank(id)) {
User user = userRes.findById(id);
if (user == null) {
// 用户不存在
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_MSG, "done");
return resp;
}
// 系统管理员 不允许 使用 接口删除
if (!user.isSuperadmin()) {
// 删除用户的时候同时删除用户对应的权限
List<UserRole> userRoles = userRoleRes.findByOrgiAndUser(user.getOrgi(), user);
userRoleRes.delete(userRoles);
// 删除用户对应的组织机构关系
List<OrganUser> organUsers = organUserRes.findByUserid(id);
organUserRes.delete(organUsers);
// 删除用户
userRes.delete(user);
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_MSG, "done");
} else {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "USER_DELETE");
}
}
} else {
// 参数不合法
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
resp.addProperty(RestUtils.RESP_KEY_ERROR, "INVALID_PARAMS");
}
return resp;
}
}

View File

@ -31,6 +31,19 @@ public class RestUtils {
public final static int RESP_RC_FAIL_5 = 5;
public final static int RESP_RC_FAIL_6 = 6;
public final static int RESP_RC_FAIL_7 = 7;
public final static int RESP_RC_FAIL_8 = 8;
public final static int RESP_RC_FAIL_9 = 9;
public final static int RESP_RC_FAIL_10 = 10;
public final static int RESP_RC_FAIL_11 = 11;
public final static int RESP_RC_FAIL_12 = 12;
public final static int RESP_RC_FAIL_13 = 13;
public final static int RESP_RC_FAIL_14 = 14;
public final static int RESP_RC_FAIL_15 = 15;
public final static int RESP_RC_FAIL_16 = 16;
public final static int RESP_RC_FAIL_17 = 17;
public final static int RESP_RC_FAIL_18 = 18;
public final static int RESP_RC_FAIL_19 = 19;
public final static int RESP_RC_FAIL_20 = 20;
// /**
// * 复制请求处理结果
@ -48,7 +61,7 @@ public class RestUtils {
// return target;
// }
public static HttpHeaders header(){
public static HttpHeaders header() {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
return headers;

View File

@ -18,7 +18,6 @@ package com.chatopera.cc.controller.apps;
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.acd.ACDAgentService;
import com.chatopera.cc.acd.ACDPolicyService;
import com.chatopera.cc.acd.basic.ACDMessageHelper;
import com.chatopera.cc.activemq.BrokerPublisher;
import com.chatopera.cc.basic.Constants;
@ -29,7 +28,6 @@ import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.exception.CSKefuException;
import com.chatopera.cc.model.*;
import com.chatopera.cc.peer.PeerSyncIM;
import com.chatopera.cc.persistence.es.QuickReplyRepository;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.*;
import com.chatopera.cc.socketio.message.Message;
@ -49,7 +47,10 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/apps/cca")
@ -59,9 +60,6 @@ public class AgentAuditController extends Handler {
@Autowired
private AgentUserProxy agentUserProxy;
@Autowired
private ACDPolicyService acdPolicyService;
@Autowired
private ACDMessageHelper acdMessageHelper;
@ -95,9 +93,6 @@ public class AgentAuditController extends Handler {
@Autowired
private OnlineUserRepository onlineUserRes;
@Autowired
private PbxHostRepository pbxHostRes;
@Autowired
private TagRepository tagRes;
@ -107,12 +102,6 @@ public class AgentAuditController extends Handler {
@Autowired
private PeerSyncIM peerSyncIM;
@Autowired
private QuickReplyRepository quickReplyRes;
@Autowired
private QuickTypeRepository quickTypeRes;
@Autowired
private TagRelationRepository tagRelationRes;
@ -128,6 +117,9 @@ public class AgentAuditController extends Handler {
@Autowired
private ACDAgentService acdAgentService;
@Autowired
private OrganProxy organProxy;
@RequestMapping(value = "/index")
@Menu(type = "cca", subtype = "cca", access = true)
public ModelAndView index(
@ -136,11 +128,13 @@ public class AgentAuditController extends Handler {
@Valid final String skill,
@Valid final String agentno,
@Valid String sort
) {
) {
final String orgi = super.getOrgi(request);
final User logined = super.getUser(request);
logger.info("[index] skill {}, agentno {}, logined {}", skill, agentno, logined.getId());
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
ModelAndView view = request(super.createAppsTempletResponse("/apps/cca/index"));
Sort defaultSort = null;
@ -164,11 +158,13 @@ public class AgentAuditController extends Handler {
}
// 坐席对话列表
List<AgentUser> agentUsers;
List<AgentUser> agentUsers = new ArrayList<>();
if (StringUtils.isBlank(skill) && StringUtils.isBlank(agentno)) {
agentUsers = agentUserRes.findByOrgiAndStatusAndAgentnoIsNot(
orgi, MainContext.AgentUserStatusEnum.INSERVICE.toString(), logined.getId(), defaultSort);
if (organs.size() > 0) {
agentUsers = agentUserRes.findByOrgiAndStatusAndSkillInAndAgentnoIsNot(
orgi, MainContext.AgentUserStatusEnum.INSERVICE.toString(), organs.keySet(), logined.getId(), defaultSort);
}
} else if (StringUtils.isNotBlank(skill) && StringUtils.isNotBlank(agentno)) {
view.addObject("skill", skill);
view.addObject("agentno", agentno);
@ -264,7 +260,7 @@ public class AgentAuditController extends Handler {
HttpServletRequest request,
String id,
String channel
) throws IOException, TemplateException {
) throws IOException, TemplateException {
String mainagentuser = "/apps/cca/mainagentuser";
if (channel.equals("phone")) {
mainagentuser = "/apps/cca/mainagentuser_callout";
@ -300,11 +296,11 @@ public class AgentAuditController extends Handler {
view.addObject(
"agentUserMessageList",
this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), orgi,
new PageRequest(0, 20, Sort.Direction.DESC,
"updatetime"
)
)
);
new PageRequest(0, 20, Sort.Direction.DESC,
"updatetime"
)
)
);
AgentService agentService = null;
if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
agentService = this.agentServiceRes.findOne(agentUser.getAgentserviceid());
@ -333,20 +329,24 @@ public class AgentAuditController extends Handler {
}
view.addObject("serviceCount", Integer
.valueOf(this.agentServiceRes
.countByUseridAndOrgiAndStatus(agentUser
.getUserid(), orgi,
MainContext.AgentUserStatusEnum.END
.toString())));
.countByUseridAndOrgiAndStatus(agentUser
.getUserid(), orgi,
MainContext.AgentUserStatusEnum.END
.toString())));
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
view.addObject("sessionConfig", sessionConfig);
if (sessionConfig.isOtherquickplay()) {
view.addObject("topicList", OnlineUserProxy.search(null, orgi, super.getUser(request)));
// TODO: mdx-organ clean
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// view.addObject("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// view.addObject("topicList", OnlineUserProxy.search(null, orgi, super.getUser(request)));
// }
AgentService service = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi);
if (service != null) {
view.addObject("tags", tagRes.findByOrgiAndTagtypeAndSkill(orgi, MainContext.ModelType.USER.toString(), service.getSkill()));
}
}
view.addObject("tags", tagRes.findByOrgiAndTagtype(orgi, MainContext.ModelType.USER.toString()));
return view;
}
@ -370,17 +370,21 @@ public class AgentAuditController extends Handler {
final @Valid String agentserviceid,
final @Valid String agentnoid,
final @Valid String agentuserid
) {
) {
logger.info("[transfer] userId {}, agentUser {}", userid, agentuserid);
final String orgi = super.getOrgi(request);
final User logined = super.getUser(request);
Organ targetOrgan = super.getOrgan(request);
Map<String, Organ> ownOrgans = organProxy.findAllOrganByParentAndOrgi(targetOrgan, super.getOrgi(request));
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
// 列出所有技能组
final List<Organ> skillGroups = OnlineUserProxy.organ(orgi, true);
List<Organ> skillGroups = organRes.findByOrgiAndIdInAndSkill(super.getOrgi(request), ownOrgans.keySet(), true);
// 选择当前用户的默认技能组
Set<String> organs = super.getUser(request).getOrgans().keySet();
String currentOrgan = organs.size() > 0 ? (new ArrayList<String>(organs)).get(0) : null;
AgentService agentService = agentServiceRes.findByIdAndOrgi(agentserviceid, super.getOrgi(request));
String currentOrgan = agentService.getSkill();
if (StringUtils.isBlank(currentOrgan)) {
if (!skillGroups.isEmpty()) {
@ -389,9 +393,8 @@ public class AgentAuditController extends Handler {
}
// 列出所有在线的坐席排除本身
final Map<String, AgentStatus> agentStatusMap = cache.findAllReadyAgentStatusByOrgi(orgi);
List<String> userids = new ArrayList<>();
final Map<String, AgentStatus> agentStatusMap = cache.findAllReadyAgentStatusByOrgi(orgi);
for (final String o : agentStatusMap.keySet()) {
if (!StringUtils.equals(o, agentnoid)) {
@ -410,7 +413,7 @@ public class AgentAuditController extends Handler {
map.addAttribute("userid", userid);
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("agentnoid", agentnoid);
map.addAttribute("agentno", agentnoid);
map.addAttribute("skillGroups", skillGroups);
map.addAttribute("agentservice", this.agentServiceRes.findByIdAndOrgi(agentserviceid, orgi));
map.addAttribute("currentorgan", currentOrgan);
@ -433,31 +436,28 @@ public class AgentAuditController extends Handler {
public ModelAndView transferagent(
ModelMap map,
HttpServletRequest request,
@Valid String agentnoid,
@Valid String agentid,
@Valid String organ
) {
) {
final User logined = super.getUser(request);
final String orgi = super.getOrgi(request);
if (StringUtils.isNotBlank(organ)) {
List<String> usersids = new ArrayList<String>();
final List<AgentStatus> agentStatusList = cache.getAgentStatusBySkillAndOrgi(organ, orgi);
if (agentStatusList.size() > 0) {
for (AgentStatus agentStatus : agentStatusList) {
if (agentStatus != null && !StringUtils.equals(agentStatus.getAgentno(), agentnoid)) {
usersids.add(agentStatus.getAgentno());
}
}
}
List<User> userList = userRes.findAll(usersids);
for (User user : userList) {
userProxy.attachOrgansPropertiesForUser(user);
for (final AgentStatus as : agentStatusList) {
if (StringUtils.equals(as.getAgentno(), user.getId())) {
user.setAgentStatus(as);
break;
}
List<String> userids = new ArrayList<>();
final Map<String, AgentStatus> agentStatusMap = cache.findAllReadyAgentStatusByOrgi(orgi);
for (final String o : agentStatusMap.keySet()) {
if (!StringUtils.equals(o, agentid)) {
userids.add(o);
}
}
final List<User> userList = userRes.findAll(userids);
for (final User o : userList) {
o.setAgentStatus(agentStatusMap.get(o.getId()));
// find user's skills
userProxy.attachOrgansPropertiesForUser(o);
}
map.addAttribute("userList", userList);
map.addAttribute("currentorgan", organ);
}
@ -486,7 +486,7 @@ public class AgentAuditController extends Handler {
@Valid final String currentAgentnoid,
@Valid final String agentno, // 会话转接给下一个坐席
@Valid final String memo
) throws CSKefuException {
) throws CSKefuException {
final String currentAgentno = currentAgentnoid; // 当前会话坐席的agentno
final String orgi = super.getOrgi(request);
@ -547,7 +547,7 @@ public class AgentAuditController extends Handler {
agentUser.getUserid(),
outMessage,
true
);
);
}
// 通知转接消息给新坐席
@ -557,7 +557,7 @@ public class AgentAuditController extends Handler {
MainContext.ReceiverType.AGENT, MainContext.ChannelType.WEBIM,
agentUser.getAppid(), MainContext.MessageType.NEW, agentService.getAgentno(),
outMessage, true
);
);
} catch (Exception ex) {
logger.error("[transfersave]", ex);

View File

@ -18,7 +18,6 @@
import com.alibaba.fastjson.JSONObject;
import com.chatopera.cc.acd.ACDAgentService;
import com.chatopera.cc.acd.ACDPolicyService;
import com.chatopera.cc.acd.ACDWorkMonitor;
import com.chatopera.cc.activemq.BrokerPublisher;
import com.chatopera.cc.basic.Constants;
@ -67,7 +66,10 @@
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/agent")
@ -78,9 +80,6 @@
@Autowired
private ACDWorkMonitor acdWorkMonitor;
@Autowired
private ACDPolicyService acdPolicyService;
@Autowired
private ACDAgentService acdAgentService;
@ -177,6 +176,12 @@
@Autowired
private UserProxy userProxy;
@Autowired
private OrganProxy organProxy;
@Autowired
private OrganRepository organRes;
/**
* 坐席从联系人列表进入坐席工作台和该联系人聊天
*
@ -449,15 +454,15 @@
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner());
if (statusEvent != null) {
if (StringUtils.isNotBlank(statusEvent.getHostid())) {
PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid());
view.addObject("pbxHost", pbxHost);
pbxHostRes.findById(statusEvent.getHostid()).ifPresent(p -> {
view.addObject("pbxHost", p);
});
}
view.addObject("statusEvent", statusEvent);
}
}
}
view.addObject("serviceCount", Integer
.valueOf(this.agentServiceRes
.countByUseridAndOrgiAndStatus(agentUser
@ -467,15 +472,17 @@
view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid()));
}
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// view.addObject("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// view.addObject("topicList", OnlineUserProxy.search(null, orgi, super.getUser(request)));
// }
view.addObject("sessionConfig", sessionConfig);
if (sessionConfig.isOtherquickplay()) {
view.addObject("topicList", OnlineUserProxy.search(null, orgi, super.getUser(request)));
AgentService service = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi);
if (service != null) {
view.addObject("tags", tagRes.findByOrgiAndTagtypeAndSkill(orgi, MainContext.ModelType.USER.toString(), service.getSkill()));
}
view.addObject("tags", tagRes.findByOrgiAndTagtype(orgi, MainContext.ModelType.USER.toString()));
view.addObject(
"quickReplyList", quickReplyRes.findByOrgiAndCreater(orgi, super.getUser(request).getId(), null));
List<QuickType> quickTypeList = quickTypeRes.findByOrgiAndQuicktype(
@ -488,31 +495,32 @@
return view;
}
@RequestMapping("/other/topic")
@Menu(type = "apps", subtype = "othertopic")
public ModelAndView othertopic(ModelMap map, HttpServletRequest request, String q) throws IOException, TemplateException {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
map.put("sessionConfig", sessionConfig);
if (sessionConfig.isOtherquickplay()) {
map.put("topicList", OnlineUserProxy.search(q, super.getOrgi(request), super.getUser(request)));
}
return request(super.createRequestPageTempletResponse("/apps/agent/othertopic"));
}
@RequestMapping("/other/topic/detail")
@Menu(type = "apps", subtype = "othertopicdetail")
public ModelAndView othertopicdetail(ModelMap map, HttpServletRequest request, String id) throws IOException, TemplateException {
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
map.put("sessionConfig", sessionConfig);
if (sessionConfig.isOtherquickplay()) {
map.put("topic", OnlineUserProxy.detail(id, super.getOrgi(request), super.getUser(request)));
}
return request(super.createRequestPageTempletResponse("/apps/agent/topicdetail"));
}
// TODO: mdx-organ clean
// @RequestMapping("/other/topic")
// @Menu(type = "apps", subtype = "othertopic")
// public ModelAndView othertopic(ModelMap map, HttpServletRequest request, String q) throws IOException, TemplateException {
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// map.put("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// map.put("topicList", OnlineUserProxy.search(q, super.getOrgi(request), super.getUser(request)));
// }
//
// return request(super.createRequestPageTempletResponse("/apps/agent/othertopic"));
// }
//
// @RequestMapping("/other/topic/detail")
// @Menu(type = "apps", subtype = "othertopicdetail")
// public ModelAndView othertopicdetail(ModelMap map, HttpServletRequest request, String id) throws IOException, TemplateException {
// SessionConfig sessionConfig = acdPolicyService.initSessionConfig(super.getOrgi(request));
//
// map.put("sessionConfig", sessionConfig);
// if (sessionConfig.isOtherquickplay()) {
// map.put("topic", OnlineUserProxy.detail(id, super.getOrgi(request), super.getUser(request)));
// }
//
// return request(super.createRequestPageTempletResponse("/apps/agent/topicdetail"));
// }
@RequestMapping("/workorders/list")
@ -992,10 +1000,12 @@
* 更新OnlineUser
*/
OnlineUser onlineUser = onlineUserRes.findOneByUseridAndOrgi(userid, agentUser.getOrgi());
onlineUser.setContactsid(contactsid);
onlineUser.setUsername(contacts.getName());
onlineUser.setUpdateuser(logined.getUname());
onlineUserRes.save(onlineUser);
if (onlineUser != null) {
onlineUser.setContactsid(contactsid);
onlineUser.setUsername(contacts.getName());
onlineUser.setUpdateuser(logined.getUname());
onlineUserRes.save(onlineUser);
}
AgentService agentService = agentServiceRes.findOne(agentserviceid);
if (agentService != null) {
@ -1071,6 +1081,7 @@
@Valid String agentserviceid,
@Valid String agentuserid,
@Valid String channel) {
final String orgi = super.getOrgi(request);
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
AgentUser agentUser = this.agentUserRes.findByIdAndOrgi(agentuserid, super.getOrgi(request));
if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
@ -1080,11 +1091,13 @@
map.addAttribute("summary", summaries.get(0));
}
}
map.addAttribute(
"tags", tagRes.findByOrgiAndTagtype(
super.getOrgi(request),
MainContext.ModelType.SUMMARY.toString()));
AgentService service = agentServiceRes.findByIdAndOrgi(agentserviceid, orgi);
if (service != null) {
map.addAttribute(
"tags", tagRes.findByOrgiAndTagtypeAndSkill(
super.getOrgi(request),
MainContext.ModelType.SUMMARY.toString(), service.getSkill()));
}
map.addAttribute("userid", userid);
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("agentuserid", agentuserid);
@ -1112,6 +1125,7 @@
AgentService service = agentServiceRes.findByIdAndOrgi(agentserviceid, orgi);
summary.setAgent(service.getAgentno());
summary.setAgentno(service.getAgentno());
summary.setSkill(service.getSkill());
summary.setUsername(service.getUsername());
summary.setAgentusername(service.getAgentusername());
summary.setChannel(service.getChannel());
@ -1148,24 +1162,18 @@
logger.info("[transfer] userId {}, agentUser {}", userid, agentuserid);
final String orgi = super.getOrgi(request);
final User logined = super.getUser(request);
Organ targetOrgan = super.getOrgan(request);
Map<String, Organ> ownOrgans = organProxy.findAllOrganByParentAndOrgi(targetOrgan, super.getOrgi(request));
if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) {
// 列出所有技能组
final List<Organ> skillGroups = OnlineUserProxy.organ(orgi, true);
// DEBUG
StringBuffer sb = new StringBuffer();
for (final Organ organ : skillGroups) {
sb.append(organ.getId());
sb.append(":");
sb.append(organ.getName());
sb.append("\t");
}
logger.info("[transfer] skillGroups {}", sb.toString());
List<Organ> skillGroups = organRes.findByOrgiAndIdInAndSkill(super.getOrgi(request), ownOrgans.keySet(), true);
// 选择当前用户的默认技能组
Set<String> organs = logined.getOrgans().keySet();
String currentOrgan = organs.size() > 0 ? (new ArrayList<String>(organs)).get(0) : null;
AgentService agentService = agentServiceRes.findByIdAndOrgi(agentserviceid, super.getOrgi(request));
String currentOrgan = agentService.getSkill();
if (StringUtils.isBlank(currentOrgan)) {
if (!skillGroups.isEmpty()) {
@ -1173,15 +1181,11 @@
}
}
logger.info("[transfer] set current organ as {}", currentOrgan);
// 列出所有在线的坐席排除本身
List<String> userids = new ArrayList<>();
final Map<String, AgentStatus> agentStatusMap = cache.findAllReadyAgentStatusByOrgi(orgi);
List<String> userids = new ArrayList<>();
for (final String o : agentStatusMap.keySet()) {
// logger.info("[transfer] agent status ready {}, status {}", agentStatusMap.get(o).getAgentno(), agentStatusMap.get(o).getStatus());
if (!StringUtils.equals(o, logined.getId())) {
userids.add(o);
}
@ -1201,6 +1205,7 @@
map.addAttribute("agentserviceid", agentserviceid);
map.addAttribute("agentuserid", agentuserid);
map.addAttribute("skillGroups", skillGroups);
map.addAttribute("agentno", agentService.getAgentno());
map.addAttribute("agentservice", this.agentServiceRes.findByIdAndOrgi(agentserviceid, orgi));
map.addAttribute("currentorgan", currentOrgan);
}
@ -1221,28 +1226,26 @@
public ModelAndView transferagent(
ModelMap map,
HttpServletRequest request,
@Valid String organ) {
@Valid String organ,
@Valid String agentid) {
final User logined = super.getUser(request);
final String orgi = super.getOrgi(request);
if (StringUtils.isNotBlank(organ)) {
List<String> usersids = new ArrayList<String>();
final List<AgentStatus> agentStatusList = cache.getAgentStatusBySkillAndOrgi(organ, orgi);
if (agentStatusList.size() > 0) {
for (AgentStatus agentStatus : agentStatusList) {
if (agentStatus != null && !StringUtils.equals(agentStatus.getAgentno(), logined.getId())) {
usersids.add(agentStatus.getAgentno());
}
List<String> userids = new ArrayList<>();
final Map<String, AgentStatus> agentStatusMap = cache.findAllReadyAgentStatusByOrgi(orgi);
for (final String o : agentStatusMap.keySet()) {
if (!StringUtils.equals(o, agentid)) {
userids.add(o);
}
}
List<User> userList = userRes.findAll(usersids);
for (User user : userList) {
userProxy.attachOrgansPropertiesForUser(user);
for (final AgentStatus as : agentStatusList) {
if (StringUtils.equals(as.getAgentno(), user.getId())) {
user.setAgentStatus(as);
break;
}
}
final List<User> userList = userRes.findAll(userids);
for (final User o : userList) {
o.setAgentStatus(agentStatusMap.get(o.getId()));
// find user's skills
userProxy.attachOrgansPropertiesForUser(o);
}
map.addAttribute("userList", userList);
map.addAttribute("currentorgan", organ);
@ -1457,7 +1460,7 @@
AgentUserContacts auc = new AgentUserContacts();
auc.setId(MainUtils.getUUID());
auc.setUsername(au.getUsername());
auc.setOrgi(MainContext.SYSTEM_ORGI);
auc.setOrgi(Constants.SYSTEM_ORGI);
auc.setUserid(au.getUserid());
auc.setContactsid(contacts.getId());
auc.setChannel(au.getChannel());

View File

@ -62,7 +62,8 @@ public class AgentQualityController extends Handler {
@RequestMapping(value = "/index")
@Menu(type = "agent", subtype = "quality", access = false)
public ModelAndView index(ModelMap map, HttpServletRequest request) {
map.addAttribute("sessionConfig", acdPolicyService.initSessionConfig(super.getOrgi(request)));
// TODO: mdx-organ clean
// map.addAttribute("sessionConfig", acdPolicyService.initSessionConfig(super.getOrgi(request)));
map.addAttribute("qualityList", qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request)));
map.addAttribute("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString()));
return request(super.createAppsTempletResponse("/apps/quality/index"));
@ -72,7 +73,7 @@ public class AgentQualityController extends Handler {
@RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "quality", access = false)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid QualityRequest qualityArray) {
String orgi = super.getOrgi(request);
String orgi = super.getOrgi(request);
if (qualityArray != null && qualityArray.getTitle() != null) {
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
@ -94,18 +95,20 @@ public class AgentQualityController extends Handler {
if (tempList.size() > 0) {
qualityRes.save(tempList);
}
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
if (config != null) {
if ("points".equals(request.getParameter("qualityscore"))) {
config.setQualityscore("points");
} else {
config.setQualityscore("score");
}
sessionConfigRes.save(config);
cache.putSessionConfigByOrgi(config, orgi);
cache.deleteSessionConfigListByOrgi(orgi);
}
// TODO: mdx-organ clean
// SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
// if (config != null) {
// if ("points".equals(request.getParameter("qualityscore"))) {
// config.setQualityscore("points");
// } else {
// config.setQualityscore("score");
// }
//
// sessionConfigRes.save(config);
// cache.putSessionConfigByOrgi(config, orgi);
// cache.deleteSessionConfigListByOrgi(orgi);
// }
if (qualityArray != null && qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
if (tagList.size() > 0) {

View File

@ -24,10 +24,12 @@ import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
@ -42,6 +44,7 @@ import javax.validation.Valid;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/setting")
@ -65,6 +68,9 @@ public class AgentSettingsController extends Handler {
@Autowired
private TemplateRepository templateRes;
@Autowired
private OrganProxy organProxy;
@Autowired
private Cache cache;
@ -74,7 +80,13 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/agent/index")
@Menu(type = "setting", subtype = "sessionconfig", admin = false)
public ModelAndView index(ModelMap map, HttpServletRequest request) {
SessionConfig sessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request));
SessionConfig sessionConfig = null;
Organ currentOrgan = super.getOrgan(request);
if (currentOrgan != null) {
sessionConfig = sessionConfigRes.findByOrgiAndSkill(super.getOrgi(request), currentOrgan.getId());
}
if (sessionConfig == null) {
sessionConfig = new SessionConfig();
}
@ -104,8 +116,10 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/agent/sessionconfig/save")
@Menu(type = "setting", subtype = "sessionconfig", admin = false)
public ModelAndView sessionconfig(ModelMap map, HttpServletRequest request, @Valid SessionConfig sessionConfig) {
SessionConfig tempSessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request));
Organ currentOrgan = super.getOrgan(request);
String orgi = super.getOrgi(request);
SessionConfig tempSessionConfig = sessionConfigRes.findByOrgiAndSkill(orgi, currentOrgan.getId());
if (tempSessionConfig == null) {
tempSessionConfig = sessionConfig;
tempSessionConfig.setCreater(super.getUser(request).getId());
@ -115,9 +129,13 @@ public class AgentSettingsController extends Handler {
tempSessionConfig.setOrgi(super.getOrgi(request));
// 强制开启满意度问卷
tempSessionConfig.setSatisfaction(true);
if (currentOrgan != null) {
tempSessionConfig.setSkill(currentOrgan.getId());
}
sessionConfigRes.save(tempSessionConfig);
cache.putSessionConfigByOrgi(tempSessionConfig, orgi);
cache.putSessionConfigByOrgi(tempSessionConfig, tempSessionConfig.getSkill(), orgi);
cache.deleteSessionConfigListByOrgi(orgi);
acdPolicyService.initSessionConfigList();
@ -129,7 +147,12 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/blacklist")
@Menu(type = "setting", subtype = "blacklist", admin = false)
public ModelAndView blacklist(ModelMap map, HttpServletRequest request) {
map.put("blackList", blackListRes.findByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime")));
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<BlackEntity> blackList = blackListRes.findByOrgiAndSkillIn(super.getOrgi(request), organs.keySet(), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"));
map.put("blackList", blackList);
map.put("tagTypeList", Dict.getInstance().getDic("com.dic.tag.type"));
return request(super.createAppsTempletResponse("/apps/setting/agent/blacklist"));
}
@ -141,7 +164,7 @@ public class AgentSettingsController extends Handler {
BlackEntity tempBlackEntity = blackListRes.findByIdAndOrgi(id, super.getOrgi(request));
if (tempBlackEntity != null) {
blackListRes.delete(tempBlackEntity);
cache.deleteSystembyIdAndOrgi(tempBlackEntity.getUserid(), MainContext.SYSTEM_ORGI);
cache.deleteSystembyIdAndOrgi(tempBlackEntity.getUserid(), Constants.SYSTEM_ORGI);
}
}
return request(super.createRequestPageTempletResponse("redirect:/setting/blacklist.html"));
@ -150,6 +173,8 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/tag")
@Menu(type = "setting", subtype = "tag", admin = false)
public ModelAndView tag(ModelMap map, HttpServletRequest request, @Valid String code) {
Organ currentOrgan = super.getOrgan(request);
SysDic tagType = null;
List<SysDic> tagList = Dict.getInstance().getDic("com.dic.tag.type");
if (tagList.size() > 0) {
@ -165,8 +190,8 @@ public class AgentSettingsController extends Handler {
}
map.put("tagType", tagType);
}
if (tagType != null) {
map.put("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request), tagType.getCode(), new PageRequest(super.getP(request), super.getPs(request))));
if (tagType != null && currentOrgan != null) {
map.put("tagList", tagRes.findByOrgiAndTagtypeAndSkill(super.getOrgi(request), tagType.getCode(), currentOrgan.getId(), new PageRequest(super.getP(request), super.getPs(request))));
}
map.put("tagTypeList", tagList);
return request(super.createAppsTempletResponse("/apps/setting/agent/tag"));
@ -190,10 +215,17 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/tag/update")
@Menu(type = "setting", subtype = "tag", admin = false)
public ModelAndView tagupdate(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
Tag temptag = tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag());
Organ currentOrgan = super.getOrgan(request);
Tag temptag = null;
if (currentOrgan != null) {
temptag = tagRes.findByOrgiAndTagAndSkill(super.getOrgi(request), tag.getTag(), currentOrgan.getId());
}
if (temptag == null || tag.getId().equals(temptag.getId())) {
tag.setOrgi(super.getOrgi(request));
tag.setCreater(super.getUser(request).getId());
tag.setSkill(currentOrgan.getId());
tagRes.save(tag);
}
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
@ -202,9 +234,12 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/tag/save")
@Menu(type = "setting", subtype = "tag", admin = false)
public ModelAndView tagsave(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) {
if (tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) == null) {
Organ currentOrgan = super.getOrgan(request);
if (currentOrgan != null && tagRes.findByOrgiAndTagAndSkill(super.getOrgi(request), tag.getTag(), currentOrgan.getId()) == null) {
tag.setOrgi(super.getOrgi(request));
tag.setCreater(super.getUser(request).getId());
tag.setSkill(currentOrgan.getId());
tagRes.save(tag);
}
return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype));
@ -229,6 +264,8 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/adv")
@Menu(type = "setting", subtype = "adv", admin = false)
public ModelAndView adv(ModelMap map, HttpServletRequest request, @Valid String adpos) {
Organ currentOrgan = super.getOrgan(request);
SysDic advType = null;
List<SysDic> tagList = Dict.getInstance().getDic("com.dic.adv.type");
if (tagList.size() > 0) {
@ -243,8 +280,8 @@ public class AgentSettingsController extends Handler {
}
map.put("advType", advType);
}
if (advType != null) {
map.put("adTypeList", adTypeRes.findByAdposAndOrgi(advType.getId(), super.getOrgi(request)));
if (currentOrgan != null && advType != null) {
map.put("adTypeList", adTypeRes.findByAdposAndOrgiAndSkill(advType.getId(), super.getOrgi(request), currentOrgan.getId()));
}
map.put("tagTypeList", Dict.getInstance().getDic("com.dic.tag.type"));
@ -264,6 +301,11 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/adv/save")
@Menu(type = "setting", subtype = "adv", admin = false)
public ModelAndView advsave(ModelMap map, HttpServletRequest request, @Valid AdType adv, @Valid String advtype, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
Organ currentOrgan = super.getOrgan(request);
if (currentOrgan != null) {
adv.setSkill(currentOrgan.getId());
}
adv.setOrgi(super.getOrgi(request));
adv.setCreater(super.getUser(request).getId());
if (StringUtils.isNotBlank(adv.getContent())) {
@ -275,7 +317,7 @@ public class AgentSettingsController extends Handler {
}
adTypeRes.save(adv);
MainUtils.initAdv(super.getOrgi(request));
MainUtils.initAdv(super.getOrgi(request), adv.getSkill());
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adv.getAdpos()));
}
@ -291,7 +333,13 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/adv/update")
@Menu(type = "setting", subtype = "adv", admin = false)
public ModelAndView advupdate(ModelMap map, HttpServletRequest request, @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException {
AdType tempad = adTypeRes.findByIdAndOrgi(ad.getId(), super.getOrgi(request));
String orgi = super.getOrgi(request);
Organ currentOrgan = super.getOrgan(request);
AdType tempad = null;
if (currentOrgan != null) {
tempad = adTypeRes.findByIdAndOrgiAndSkill(ad.getId(), super.getOrgi(request), currentOrgan.getId());
}
if (tempad != null) {
ad.setOrgi(super.getOrgi(request));
ad.setCreater(tempad.getCreater());
@ -304,8 +352,9 @@ public class AgentSettingsController extends Handler {
} else {
ad.setImgurl(tempad.getImgurl());
}
ad.setSkill(currentOrgan.getId());
adTypeRes.save(ad);
MainUtils.initAdv(super.getOrgi(request));
MainUtils.initAdv(orgi, tempad.getSkill());
}
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
}
@ -313,8 +362,12 @@ public class AgentSettingsController extends Handler {
@RequestMapping("/adv/delete")
@Menu(type = "setting", subtype = "adv", admin = false)
public ModelAndView advdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String adpos) {
adTypeRes.delete(id);
MainUtils.initAdv(super.getOrgi(request));
String orgi = super.getOrgi(request);
AdType adType = adTypeRes.findByIdAndOrgi(id, orgi);
if (adType != null) {
adTypeRes.delete(id);
MainUtils.initAdv(orgi, adType.getSkill());
}
return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos));
}
}

View File

@ -23,10 +23,8 @@ import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.persistence.repository.OnlineUserRepository;
import com.chatopera.cc.persistence.repository.OrgiSkillRelRepository;
import com.chatopera.cc.persistence.repository.UserEventRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
@ -46,6 +44,7 @@ import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller
public class AppsController extends Handler {
@ -75,20 +74,34 @@ public class AppsController extends Handler {
@Autowired
private UserProxy userProxy;
@Autowired
private OrganProxy organProxy;
@Autowired
private ConsultInviteRepository invite;
@RequestMapping({"/apps/content"})
@Menu(type = "apps", subtype = "content")
public ModelAndView content(ModelMap map, HttpServletRequest request, @Valid String msg) {
final User user = super.getUser(request);
final String orgi = super.getOrgi(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, orgi);
List<String> appids = new ArrayList<String>();
if (organs.size() > 0) {
appids = invite.findSNSIdByOrgiAndSkill(orgi, organs.keySet());
}
/****************************
* 获得在线访客列表
****************************/
// TODO 此处为从数据库加载
final Page<OnlineUser> onlineUserList = onlineUserRes.findByOrgiAndStatus(
final Page<OnlineUser> onlineUserList = onlineUserRes.findByOrgiAndStatusAndAppidIn(
super.getOrgi(request),
MainContext.OnlineUserStatusEnum.ONLINE.toString(),
appids,
new PageRequest(
super.getP(request),
super.getPs(request),
@ -139,19 +152,33 @@ public class AppsController extends Handler {
}
private void aggValues(ModelMap map, HttpServletRequest request) {
map.put("agentReport", acdWorkMonitor.getAgentReport(super.getOrgi(request)));
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
List<Object> onlineUsers = new ArrayList<>();
List<Object> userEvents = new ArrayList<>();
if (organs.size() > 0) {
List<String> appids = invite.findSNSIdByOrgiAndSkill(super.getOrgi(request), organs.keySet());
if (appids.size() > 0) {
onlineUsers = onlineUserRes.findByOrgiAndStatusAndInAppIds(
super.getOrgi(request),
MainContext.OnlineUserStatusEnum.ONLINE.toString(), appids);
userEvents = userEventRes.findByOrgiAndCreatetimeRangeAndInAppIds(super.getOrgi(request), MainUtils.getStartTime(),
MainUtils.getEndTime(), appids);
}
}
map.put("agentReport", acdWorkMonitor.getAgentReport(currentOrgan != null ? currentOrgan.getId() : null, super.getOrgi(request)));
map.put(
"webIMReport", MainUtils.getWebIMReport(
userEventRes.findByOrgiAndCreatetimeRange(super.getOrgi(request), MainUtils.getStartTime(),
MainUtils.getEndTime())));
"webIMReport", MainUtils.getWebIMReport(userEvents));
// TODO 此处为什么不用agentReport中的agents
map.put("agents", getUsers(request).size());
map.put(
"webIMInvite", MainUtils.getWebIMInviteStatus(onlineUserRes.findByOrgiAndStatus(
super.getOrgi(request),
MainContext.OnlineUserStatusEnum.ONLINE.toString())));
"webIMInvite", MainUtils.getWebIMInviteStatus(onlineUsers));
map.put(
"inviteResult", MainUtils.getWebIMInviteResult(
@ -254,7 +281,7 @@ public class AppsController extends Handler {
tempUser.setAgent(true);
}
tempUser.setOrgi(super.getOrgiByTenantshare(request));
tempUser.setOrgi(super.getOrgi());
final Date now = new Date();
if (StringUtils.isNotBlank(user.getPassword())) {
tempUser.setPassword(MainUtils.md5(user.getPassword()));
@ -299,19 +326,12 @@ public class AppsController extends Handler {
* @return
*/
private List<User> getUsers(HttpServletRequest request) {
List<User> userList;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
userList = userProxy.findByOrganInAndAgentAndDatastatus(organIdList, true, false);
} else {
userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(super.getOrgan(request), super.getOrgi(request));
List<User> userList = userProxy.findByOrganInAndAgentAndDatastatus(organs.keySet(), true, false);
if (userList == null) {
userList = new ArrayList<>();
}
return userList;
}

View File

@ -19,13 +19,11 @@ package com.chatopera.cc.controller.apps;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.exception.CSKefuException;
import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.MetadataTable;
import com.chatopera.cc.model.PropertiesEvent;
import com.chatopera.cc.model.User;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.ContactsProxy;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.PinYinTools;
import com.chatopera.cc.util.PropertiesEventUtil;
@ -60,6 +58,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
@Controller
@RequestMapping("/apps/contacts")
@ -85,6 +84,12 @@ public class ContactsController extends Handler {
@Autowired
private OrganRepository organRes;
@Autowired
private OrganProxy organProxy;
@Autowired
private AgentServiceRepository agentServiceRes;
@Autowired
private AgentUserContactsRepository agentUserContactsRes;
@ -112,12 +117,17 @@ public class ContactsController extends Handler {
map.put("q", q);
}
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (StringUtils.isNotBlank(ckind)) {
boolQueryBuilder.must(termQuery("ckind", ckind));
map.put("ckind", ckind);
}
map.addAttribute("currentOrgan",currentOrgan);
Page<Contacts> contacts = contactsRes.findByCreaterAndSharesAndOrgi(
logined.getId(),
logined.getId(),
@ -142,6 +152,11 @@ public class ContactsController extends Handler {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
}
@ -177,6 +192,11 @@ public class ContactsController extends Handler {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
}
@ -211,6 +231,11 @@ public class ContactsController extends Handler {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/contacts/index"));
}
@ -270,6 +295,7 @@ public class ContactsController extends Handler {
@RequestParam(name = "idselflocation", required = false) String selflocation) {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
Organ currentOrgan = super.getOrgan(request);
String skypeIDReplace = contactsProxy.sanitizeSkypeId(contacts.getSkypeid());
String msg = "";
List<Contacts> contact = contactsRes.findByskypeidAndDatastatus(skypeIDReplace, false);
@ -279,6 +305,11 @@ public class ContactsController extends Handler {
logger.info("[save] 数据库没有相同skypeid");
contacts.setCreater(logined.getId());
contacts.setOrgi(orgi);
if (currentOrgan != null && StringUtils.isBlank(contacts.getOrgan())) {
contacts.setOrgan(currentOrgan.getId());
}
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
if (StringUtils.isBlank(contacts.getCusbirthday())) {
contacts.setCusbirthday(null);
@ -351,7 +382,7 @@ public class ContactsController extends Handler {
@RequestMapping("/update")
@Menu(type = "contacts", subtype = "contacts")
public ModelAndView update(HttpServletRequest request, @Valid Contacts contacts , @Valid String ckindId) {
public ModelAndView update(HttpServletRequest request, @Valid Contacts contacts, @Valid String ckindId) {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
Contacts data = contactsRes.findOne(contacts.getId());
@ -400,6 +431,7 @@ public class ContactsController extends Handler {
contacts.setSkypeid(contacts.getSkypeid());
contacts.setCreater(data.getCreater());
contacts.setOrgan(data.getOrgan());
contacts.setCreatetime(data.getCreatetime());
contacts.setOrgi(logined.getOrgi());
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
@ -428,6 +460,9 @@ public class ContactsController extends Handler {
public ModelAndView impsave(ModelMap map, HttpServletRequest request, @RequestParam(value = "cusfile", required = false) MultipartFile cusfile, @Valid String ckind) throws IOException {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
Organ currentOrgan = super.getOrgan(request);
String organId = currentOrgan != null ? currentOrgan.getId() : null;
DSDataEvent event = new DSDataEvent();
String fileName = "contacts/" + MainUtils.getUUID() + cusfile.getOriginalFilename().substring(
cusfile.getOriginalFilename().lastIndexOf("."));
@ -443,6 +478,8 @@ public class ContactsController extends Handler {
event.getDSData().setProcess(new ContactsProcess(contactsRes));
event.setOrgi(orgi);
event.getValues().put("creater", logined.getId());
event.getValues().put("organ", organId);
event.getValues().put("shares", "all");
reporterRes.save(event.getDSData().getReport());
new ExcelImportProecess(event).process(); //启动导入任务
}
@ -484,13 +521,23 @@ public class ContactsController extends Handler {
@RequestMapping("/expall")
@Menu(type = "contacts", subtype = "contacts")
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws IOException, CSKefuException {
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String ckind) throws IOException, CSKefuException {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return;
}
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (StringUtils.isNotBlank(ckind)) {
boolQueryBuilder.must(termQuery("ckind", ckind));
map.put("ckind", ckind);
}
boolQueryBuilder.must(termQuery("datastatus", false)); //只导出 数据删除状态 未删除的 数据
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(
logined.getId(), logined.getId(), orgi, null, null,
@ -514,16 +561,21 @@ public class ContactsController extends Handler {
@RequestMapping("/expsearch")
@Menu(type = "contacts", subtype = "contacts")
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String q, @Valid String ekind) throws IOException {
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String q, @Valid String ckind) throws IOException {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (StringUtils.isNotBlank(q)) {
map.put("q", q);
}
if (StringUtils.isNotBlank(ekind)) {
boolQueryBuilder.must(termQuery("ekind", ekind));
map.put("ekind", ekind);
if (StringUtils.isNotBlank(ckind)) {
boolQueryBuilder.must(termQuery("ckind", ckind));
map.put("ckind", ckind);
}
Iterable<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(
@ -549,7 +601,7 @@ public class ContactsController extends Handler {
@RequestMapping("/embed/index")
@Menu(type = "customer", subtype = "embed")
public ModelAndView embed(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind, @Valid String msg, @Valid String userid) throws CSKefuException {
public ModelAndView embed(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ckind, @Valid String msg, @Valid String userid, @Valid String agentserviceid) throws CSKefuException {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
@ -560,10 +612,17 @@ public class ContactsController extends Handler {
if (StringUtils.isNotBlank(q)) {
map.put("q", q);
}
if (StringUtils.isNotBlank(agentserviceid)) {
map.put("agentserviceid", agentserviceid);
}
if (StringUtils.isNotBlank(ckind)) {
boolQueryBuilder.must(termQuery("ckind", ckind));
map.put("ckind", ckind);
}
if (StringUtils.isNotBlank(agentserviceid)) {
AgentService service = agentServiceRes.findByIdAndOrgi(agentserviceid, orgi);
boolQueryBuilder.must(termQuery("organ", service.getSkill()));
}
Page<Contacts> contactsList = contactsRes.findByCreaterAndSharesAndOrgi(
logined.getId(), logined.getId(), orgi, null, null, false, boolQueryBuilder, q,
new PageRequest(super.getP(request), super.getPs(request)));
@ -582,15 +641,19 @@ public class ContactsController extends Handler {
@RequestMapping("/embed/add")
@Menu(type = "contacts", subtype = "embedadd")
public ModelAndView embedadd(ModelMap map, HttpServletRequest request) {
public ModelAndView embedadd(ModelMap map, HttpServletRequest request, @Valid String agentserviceid) {
if (StringUtils.isNotBlank(agentserviceid)) {
map.put("agentserviceid", agentserviceid);
}
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/add"));
}
@RequestMapping("/embed/save")
@Menu(type = "contacts", subtype = "embedsave")
public ModelAndView embedsave(HttpServletRequest request, @Valid Contacts contacts) {
public ModelAndView embedsave(HttpServletRequest request, @Valid Contacts contacts, @Valid String agentserviceid) {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
Organ currentOrgan = super.getOrgan(request);
String skypeIDReplace = contactsProxy.sanitizeSkypeId(contacts.getSkypeid());
String msg = "";
List<Contacts> contact = contactsRes.findByskypeidAndDatastatus(skypeIDReplace, false);
@ -599,6 +662,12 @@ public class ContactsController extends Handler {
if (contacts.getSkypeid() != null && contact.size() == 0) {
contacts.setCreater(logined.getId());
contacts.setOrgi(logined.getOrgi());
if (StringUtils.isNotBlank(agentserviceid)) {
AgentService agentService = agentServiceRes.findOne(agentserviceid);
contacts.setOrgan(agentService.getSkill());
}
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
if (StringUtils.isBlank(contacts.getCusbirthday())) {
contacts.setCusbirthday(null);
@ -606,22 +675,25 @@ public class ContactsController extends Handler {
contactsRes.save(contacts);
msg = "new_contacts_success";
return request(
super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg));
super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
msg = "new_contacts_fail";
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg));
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
@RequestMapping("/embed/edit")
@Menu(type = "contacts", subtype = "embededit")
public ModelAndView embededit(ModelMap map, HttpServletRequest request, @Valid String id) {
public ModelAndView embededit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String agentserviceid) {
map.addAttribute("contacts", contactsRes.findOne(id));
if (StringUtils.isNotBlank(agentserviceid)) {
map.addAttribute("agentserviceid", agentserviceid);
}
return request(super.createRequestPageTempletResponse("/apps/business/contacts/embed/edit"));
}
@RequestMapping("/embed/update")
@Menu(type = "contacts", subtype = "embedupdate")
public ModelAndView embedupdate(HttpServletRequest request, @Valid Contacts contacts) {
public ModelAndView embedupdate(HttpServletRequest request, @Valid Contacts contacts, @Valid String agentserviceid) {
final User logined = super.getUser(request);
final String orgi = logined.getOrgi();
Contacts data = contactsRes.findOne(contacts.getId());
@ -642,13 +714,13 @@ public class ContactsController extends Handler {
msg = "edit_contacts_success";
} else {
//无修改直接点击确定
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html"));
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?agentserviceid=" + agentserviceid));
}
} else {
logger.info("[contacts edit] errer :The same skypeid exists");
msg = "edit_contacts_fail";
return request(
super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg));
super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
List<PropertiesEvent> events = PropertiesEventUtil.processPropertiesModify(
@ -668,6 +740,7 @@ public class ContactsController extends Handler {
contacts.setSkypeid(contacts.getSkypeid());
contacts.setCreater(data.getCreater());
contacts.setOrgan(data.getOrgan());
contacts.setCreatetime(data.getCreatetime());
contacts.setOrgi(logined.getOrgi());
contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName()));
@ -680,6 +753,6 @@ public class ContactsController extends Handler {
if (msg.equals("edit_contacts_success")) {
contactsRes.save(contacts);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg));
return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html?msg=" + msg + "&agentserviceid=" + agentserviceid));
}
}

View File

@ -27,6 +27,7 @@ import com.chatopera.cc.persistence.es.EntCustomerRepository;
import com.chatopera.cc.persistence.repository.MetadataRepository;
import com.chatopera.cc.persistence.repository.PropertiesEventRepository;
import com.chatopera.cc.persistence.repository.ReporterRepository;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.PinYinTools;
import com.chatopera.cc.util.PropertiesEventUtil;
@ -60,6 +61,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
@Controller
@RequestMapping("/apps/customer")
@ -81,6 +83,9 @@ public class CustomerController extends Handler {
@Autowired
private PropertiesEventRepository propertiesEventRes;
@Autowired
private OrganProxy organProxy;
@Value("${web.upload-path}")
private String path;
@ -94,6 +99,11 @@ public class CustomerController extends Handler {
logger.info("[index] query {}, ekind {}, msg {}", q, ekind, msg);
final User logined = super.getUser(request);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
map.put("msg", msg);
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
@ -107,6 +117,8 @@ public class CustomerController extends Handler {
map.put("ekind", ekind);
}
map.addAttribute("currentOrgan",currentOrgan);
map.addAttribute("entCustomerList", entCustomerRes.findByCreaterAndSharesAndOrgi(logined.getId(),
logined.getId(),
super.getOrgi(request),
@ -125,6 +137,10 @@ public class CustomerController extends Handler {
public ModelAndView today(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ekind) throws CSKefuException {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
}
@ -146,6 +162,11 @@ public class CustomerController extends Handler {
@Menu(type = "customer", subtype = "week")
public ModelAndView week(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ekind) throws CSKefuException {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
}
@ -166,6 +187,11 @@ public class CustomerController extends Handler {
@Menu(type = "customer", subtype = "enterprise")
public ModelAndView enterprise(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ekind) throws CSKefuException {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
}
@ -186,6 +212,11 @@ public class CustomerController extends Handler {
@Menu(type = "customer", subtype = "personal")
public ModelAndView personal(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ekind) throws CSKefuException {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
}
@ -208,6 +239,11 @@ public class CustomerController extends Handler {
@Menu(type = "customer", subtype = "creater")
public ModelAndView creater(ModelMap map, HttpServletRequest request, @Valid String q, @Valid String ekind) throws CSKefuException {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (!super.esOrganFilter(request, boolQueryBuilder)) {
return request(super.createAppsTempletResponse("/apps/business/customer/index"));
}
@ -243,9 +279,15 @@ public class CustomerController extends Handler {
customerGroupForm.getEntcustomer().setOrgi(super.getOrgi(request));
final User logined = super.getUser(request);
Organ currentOrgan = super.getOrgan(request);
// customerGroupForm.getEntcustomer().setEtype(MainContext.CustomerTypeEnum.ENTERPRISE.toString());
customerGroupForm.getEntcustomer().setPinyin(PinYinTools.getInstance().getFirstPinYin(customerGroupForm.getEntcustomer().getName()));
if (currentOrgan != null && StringUtils.isBlank(customerGroupForm.getEntcustomer().getOrgan())) {
customerGroupForm.getEntcustomer().setOrgan(currentOrgan.getId());
customerGroupForm.getContacts().setOrgan(currentOrgan.getId());
}
entCustomerRes.save(customerGroupForm.getEntcustomer());
if (customerGroupForm.getContacts() != null && StringUtils.isNotBlank(customerGroupForm.getContacts().getName())) {
customerGroupForm.getContacts().setEntcusid(customerGroupForm.getEntcustomer().getId());
@ -255,6 +297,7 @@ public class CustomerController extends Handler {
if (StringUtils.isBlank(customerGroupForm.getContacts().getCusbirthday())) {
customerGroupForm.getContacts().setCusbirthday(null);
}
contactsRes.save(customerGroupForm.getContacts());
}
return request(super.createRequestPageTempletResponse("redirect:/apps/customer/index.html?ekind=" + customerGroupForm.getEntcustomer().getEkind() + "&msg=" + msg));
@ -300,7 +343,7 @@ public class CustomerController extends Handler {
propertiesEventRes.save(event);
}
}
customerGroupForm.getEntcustomer().setOrgan(customer.getOrgan());
customerGroupForm.getEntcustomer().setCreater(customer.getCreater());
customerGroupForm.getEntcustomer().setCreatetime(customer.getCreatetime());
customerGroupForm.getEntcustomer().setOrgi(logined.getOrgi());
@ -326,6 +369,10 @@ public class CustomerController extends Handler {
if (!excelFile.getParentFile().exists()) {
excelFile.getParentFile().mkdirs();
}
Organ currentOrgan = super.getOrgan(request);
String organId = currentOrgan != null ? currentOrgan.getId() : null;
MetadataTable table = metadataRes.findByTablename("uk_entcustomer");
if (table != null) {
FileUtils.writeByteArrayToFile(new File(path, fileName), cusfile.getBytes());
@ -337,6 +384,8 @@ public class CustomerController extends Handler {
exchange.getValues().put("ekind", ekind) ;
}*/
event.getValues().put("creater", super.getUser(request).getId());
event.getValues().put("organ", organId);
event.getValues().put("shares", "all");
reporterRes.save(event.getDSData().getReport());
new ExcelImportProecess(event).process(); //启动导入任务
}
@ -355,7 +404,7 @@ public class CustomerController extends Handler {
values.add(MainUtils.transBean2Map(customer));
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-EntCustomer-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-EntCustomer-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
excelProcess.process();
@ -366,13 +415,22 @@ public class CustomerController extends Handler {
@RequestMapping("/expall")
@Menu(type = "customer", subtype = "customer")
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws IOException, CSKefuException {
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response ,@Valid String ekind) throws IOException, CSKefuException {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (!super.esOrganFilter(request, boolQueryBuilder)) {
// #TODO 提示没有部门
return;
}
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (StringUtils.isNotBlank(ekind)) {
boolQueryBuilder.must(termQuery("ekind", ekind));
map.put("ekind", ekind);
}
boolQueryBuilder.must(termQuery("datastatus", false)); //只导出 数据删除状态 未删除的 数据
Iterable<EntCustomer> entCustomerList = entCustomerRes.findByCreaterAndSharesAndOrgi(super.getUser(request).getId(), super.getUser(request).getId(), super.getOrgi(request), null, null, false, boolQueryBuilder, null, new PageRequest(super.getP(request), super.getPs(request)));
@ -382,7 +440,7 @@ public class CustomerController extends Handler {
values.add(MainUtils.transBean2Map(customer));
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-EntCustomer-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-EntCustomer-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
excelProcess.process();
@ -398,6 +456,10 @@ public class CustomerController extends Handler {
return;
}
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
boolQueryBuilder.must(termsQuery("organ", organs.keySet()));
if (StringUtils.isNotBlank(q)) {
map.put("q", q);
}
@ -413,7 +475,7 @@ public class CustomerController extends Handler {
values.add(MainUtils.transBean2Map(customer));
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-EntCustomer-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-EntCustomer-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
excelProcess.process();

View File

@ -172,7 +172,7 @@ public class EntIMController extends Handler {
@Menu(type = "im", subtype = "entim", access = false)
public ModelAndView chat(HttpServletRequest request, HttpServletResponse response, @Valid String userid) {
ModelAndView view = request(super.createEntIMTempletResponse("/apps/entim/chat"));
User entImUser = userRes.findByIdAndOrgi(userid, super.getOrgi(request));
User entImUser = userRes.findById(userid);
if (entImUser != null) {
userProxy.attachOrgansPropertiesForUser(entImUser);

View File

@ -1,189 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.apps;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Extention;
import com.chatopera.cc.model.PbxHost;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.Template;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/apps/callcenter")
public class ExtentionController extends Handler{
@Autowired
private PbxHostRepository pbxHostRes ;
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private AclRepository aclRes;
@Autowired
private RouterRulesRepository routerRes;
@Autowired
private SkillExtentionRepository skillExtentionRes ;
@Autowired
private CallCenterSkillRepository skillRes ;
@Autowired
private SipTrunkRepository sipTrunkRes ;
@RequestMapping(value = "/extention")
@Menu(type = "callcenter" , subtype = "extention" , access = true)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/index")) ;
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname) ;
PbxHost pbxHost = null ;
SystemConfig systemConfig = MainUtils.getSystemConfig() ;
if(pbxHostList!=null && pbxHostList.size() > 0){
pbxHost = pbxHostList.get(0) ;
map.addAttribute("pbxHost" , pbxHost);
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("extentionList" , extentionRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
}
if(systemConfig!=null && systemConfig.isCallcenter()){
if(!StringUtils.isBlank(systemConfig.getCc_extention())){
Template template = MainUtils.getTemplate(systemConfig.getCc_extention()) ;
if(template!=null){
map.addAttribute("template" , template);
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template")) ;
}
}
}
return view ;
}
@RequestMapping(value = "/configuration")
@Menu(type = "callcenter" , subtype = "configuration" , access = true)
public ModelAndView configuration(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value , @Valid String profile) {
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname) ;
PbxHost pbxHost = null ;
SystemConfig systemConfig = MainUtils.getSystemConfig() ;
if(pbxHostList!=null && pbxHostList.size() > 0){
pbxHost = pbxHostList.get(0) ;
map.addAttribute("pbxHost" , pbxHost);
map.addAttribute("skillGroups" , skillRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("skillExtentionList" , skillExtentionRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("extentionList" , extentionRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("aclList" , aclRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
map.addAttribute("sipTrunkList" , sipTrunkRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
}
Template template = null ;
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/notfound"));
if(key_value!=null && key_value.equals("callcenter.conf")){
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/callcenter"));
if(systemConfig!=null && systemConfig.isCallcenter()){
if(!StringUtils.isBlank(systemConfig.getCc_quene())){
template = MainUtils.getTemplate(systemConfig.getCc_quene()) ;
}
}
}else if(key_value!=null && key_value.equals("acl.conf")){
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/acl"));
if(systemConfig!=null && systemConfig.isCallcenter()){
if(!StringUtils.isBlank(systemConfig.getCc_acl())){
template = MainUtils.getTemplate(systemConfig.getCc_acl()) ;
}
}
}else if(key_value!=null && key_value.equals("ivr.conf")){
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/configure/ivr"));
if(systemConfig!=null && systemConfig.isCallcenter()){
if(!StringUtils.isBlank(systemConfig.getCc_ivr())){
template = MainUtils.getTemplate(systemConfig.getCc_ivr()) ;
}
}
}
if(template!=null){
map.addAttribute("template" , template);
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template")) ;
}
return view;
}
@RequestMapping(value = "/dialplan")
@Menu(type = "callcenter" , subtype = "dialplan" , access = true)
public ModelAndView dialplan(ModelMap map , HttpServletRequest request , @Valid String hostname , @Valid String key_value) {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/dialplan/index"));
List<PbxHost> pbxHostList = pbxHostRes.findByHostnameOrIpaddr(hostname, hostname) ;
PbxHost pbxHost = null ;
SystemConfig systemConfig = MainUtils.getSystemConfig() ;
Template template = null ;
if(pbxHostList!=null && pbxHostList.size() > 0){
pbxHost = pbxHostList.get(0) ;
map.addAttribute("pbxHost" , pbxHost);
map.addAttribute("routerList" , routerRes.findByHostidAndOrgi(pbxHost.getId() , super.getOrgi(request)));
}
if(systemConfig!=null && systemConfig.isCallcenter()){
if(!StringUtils.isBlank(systemConfig.getCc_siptrunk())){
template = MainUtils.getTemplate(systemConfig.getCc_router()) ;
}
if(template!=null){
map.addAttribute("template" , template);
view = request(super.createRequestPageTempletResponse("/apps/business/callcenter/template")) ;
}
}
return view;
}
@RequestMapping(value = "/extention/detail")
@Menu(type = "callcenter" , subtype = "extention" , access = false)
public ModelAndView detail(ModelMap map , HttpServletRequest request , HttpServletResponse response ,@Valid String extno) {
List<Extention> extentionList = extentionRes.findByExtentionAndOrgi(extno, super.getOrgi(request)) ;
if(extentionList!=null && extentionList.size() == 1){
Extention extention = extentionList.get(0) ;
if(!StringUtils.isBlank(extention.getHostid())) {
PbxHost pbxHost = pbxHostRes.findById(extention.getHostid()) ;
if(pbxHost!=null) {
map.addAttribute("pbxhost" , pbxHost);
}
}
map.addAttribute("extention" , extention);
}
response.setContentType("Content-type: text/json; charset=utf-8");
return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/detail"));
}
@RequestMapping(value = "/ivr")
@Menu(type = "callcenter" , subtype = "ivr" , access = false)
public ModelAndView ivr(ModelMap map , HttpServletRequest request , HttpServletResponse response ,@Valid String hostid) {
map.addAttribute("ivrList" , extentionRes.findByHostidAndExtypeAndOrgi(hostid, MainContext.ExtentionType.BUSINESS.toString() , super.getOrgi(request)));
return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/ivr"));
}
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* Modifications copyright (C) 2018-2020 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -62,7 +62,10 @@ import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Controller
@RequestMapping("/im")
@ -207,7 +210,7 @@ public class IMController extends Handler {
view.addObject("ip", MainUtils.md5(request.getRemoteAddr()));
view.addObject("mobile", MobileDevice.isMobile(request.getHeader("User-Agent")));
CousultInvite invite = OnlineUserProxy.consult(id, MainContext.SYSTEM_ORGI);
CousultInvite invite = OnlineUserProxy.consult(id, Constants.SYSTEM_ORGI);
if (invite != null) {
logger.info("[point] find CousultInvite {}", invite.getId());
view.addObject("inviteData", invite);
@ -244,7 +247,7 @@ public class IMController extends Handler {
if (imUser != null) {
userHistory.setCreater(imUser.getId());
userHistory.setUsername(imUser.getUsername());
userHistory.setOrgi(MainContext.SYSTEM_ORGI);
userHistory.setOrgi(Constants.SYSTEM_ORGI);
}
if (StringUtils.isNotBlank(title)) {
@ -277,11 +280,11 @@ public class IMController extends Handler {
/***
* 查询 技能组 缓存
*/
view.addObject("skillGroups", OnlineUserProxy.organ(MainContext.SYSTEM_ORGI, ipdata, invite, true));
view.addObject("skillGroups", OnlineUserProxy.organ(Constants.SYSTEM_ORGI, ipdata, invite, true));
/**
* 查询坐席 缓存
*/
view.addObject("agentList", OnlineUserProxy.agents(MainContext.SYSTEM_ORGI));
view.addObject("agentList", OnlineUserProxy.agents(Constants.SYSTEM_ORGI));
}
view.addObject("traceid", userHistory.getId());
@ -291,12 +294,12 @@ public class IMController extends Handler {
view.addObject(
"pointAd",
MainUtils.getPointAdv(MainContext.AdPosEnum.POINT.toString(), MainContext.SYSTEM_ORGI));
MainUtils.getPointAdv(MainContext.AdPosEnum.POINT.toString(), invite.getConsult_skill_fixed_id(), Constants.SYSTEM_ORGI));
view.addObject(
"inviteAd",
MainUtils.getPointAdv(MainContext.AdPosEnum.INVITE.toString(), MainContext.SYSTEM_ORGI));
MainUtils.getPointAdv(MainContext.AdPosEnum.INVITE.toString(), invite.getConsult_skill_fixed_id(), Constants.SYSTEM_ORGI));
} else {
logger.info("[point] invite id {}, orgi {} not found", id, MainContext.SYSTEM_ORGI);
logger.info("[point] invite id {}, orgi {} not found", id, Constants.SYSTEM_ORGI);
}
}
@ -318,7 +321,7 @@ public class IMController extends Handler {
if (data == null) {
data = new Contacts();
data.setCreater(gid);
data.setOrgi(MainContext.SYSTEM_ORGI);
data.setOrgi(Constants.SYSTEM_ORGI);
data.setWluid(uid);
data.setWlusername(username);
data.setWlcid(cid);
@ -363,7 +366,7 @@ public class IMController extends Handler {
sessionMessage.put("Sessionsystem_name", system_name);
sessionMessage.put("sessionid", sessionid);
sessionMessage.put("uid", uid);
cache.putSystemMapByIdAndOrgi(sessionid, MainContext.SYSTEM_ORGI, sessionMessage);
cache.putSystemMapByIdAndOrgi(sessionid, Constants.SYSTEM_ORGI, sessionMessage);
OnlineUser onlineUser = onlineUserRes.findOne(userid);
String updateusername;
@ -381,9 +384,9 @@ public class IMController extends Handler {
} else {
if (!whitelist_mode) {
createContacts(userid,
request,
logined.getId(),
uid, cid, sid, username, company_name, system_name);
request,
logined.getId(),
uid, cid, sid, username, company_name, system_name);
}
}
@ -396,7 +399,7 @@ public class IMController extends Handler {
public void inlist(HttpServletRequest request, HttpServletResponse response, @PathVariable String id, @Valid String userid) throws IOException {
response.setHeader("Content-Type", "text/html;charset=utf-8");
if (StringUtils.isNotBlank(userid)) {
BlackEntity black = cache.findOneSystemByIdAndOrgi(userid, MainContext.SYSTEM_ORGI);
BlackEntity black = cache.findOneSystemByIdAndOrgi(userid, Constants.SYSTEM_ORGI);
if ((black != null && (black.getEndtime() == null || black.getEndtime().after(new Date())))) {
response.getWriter().write("in");
}
@ -583,11 +586,12 @@ public class IMController extends Handler {
}
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/index"));
Optional<BlackEntity> blackOpt = cache.findOneBlackEntityByUserIdAndOrgi(userid, MainContext.SYSTEM_ORGI);
Optional<BlackEntity> blackOpt = cache.findOneBlackEntityByUserIdAndOrgi(userid, Constants.SYSTEM_ORGI);
CousultInvite invite = OnlineUserProxy.consult(appid, orgi);
if (StringUtils.isNotBlank(
appid) && ((!blackOpt.isPresent()) || (blackOpt.get().getEndtime() != null && blackOpt.get().getEndtime().before(
new Date())))) {
CousultInvite invite = OnlineUserProxy.consult(appid, orgi);
String randomUserId; // 随机生成OnlineUser的用户名使用了浏览器指纹做唯一性KEY
if (StringUtils.isNotBlank(userid)) {
randomUserId = MainUtils.genIDByKey(userid);
@ -610,7 +614,7 @@ public class IMController extends Handler {
view.addObject("nickname", nickname);
boolean consult = true; //是否已收集用户信息
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(orgi);
SessionConfig sessionConfig = acdPolicyService.initSessionConfig(skill, orgi);
// 强制开启满意调查问卷
sessionConfig.setSatisfaction(true);
@ -890,13 +894,13 @@ public class IMController extends Handler {
map.addAttribute(
"chatMessageList", chatMessageRes.findByUsessionAndOrgi(userid, orgi, new PageRequest(0, 20,
Direction.DESC,
"updatetime")));
Direction.DESC,
"updatetime")));
}
view.addObject("commentList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_DIC));
view.addObject("commentItemList", Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_ITEM_DIC));
view.addObject("welcomeAd", MainUtils.getPointAdv(MainContext.AdPosEnum.WELCOME.toString(), orgi));
view.addObject("imageAd", MainUtils.getPointAdv(MainContext.AdPosEnum.IMAGE.toString(), orgi));
view.addObject("welcomeAd", MainUtils.getPointAdv(MainContext.AdPosEnum.WELCOME.toString(), skill, orgi));
view.addObject("imageAd", MainUtils.getPointAdv(MainContext.AdPosEnum.IMAGE.toString(), skill, orgi));
// 确定"接受邀请"被处理后通知浏览器关闭弹出窗口
OnlineUserProxy.sendWebIMClients(userid, "accept");
@ -923,6 +927,8 @@ public class IMController extends Handler {
} else {
logger.info("[index] can not invite for appid {}, orgi {}", appid, orgi);
}
} else {
view.addObject("inviteData", invite);
}
logger.info("[index] return view");
@ -956,7 +962,7 @@ public class IMController extends Handler {
@Valid String purl) throws Exception {
ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/text"));
CousultInvite invite = OnlineUserProxy.consult(
appid, StringUtils.isBlank(orgi) ? MainContext.SYSTEM_ORGI : orgi);
appid, StringUtils.isBlank(orgi) ? Constants.SYSTEM_ORGI : orgi);
view.addObject("hostname", request.getServerName());
view.addObject("port", request.getServerPort());
@ -1023,17 +1029,22 @@ public class IMController extends Handler {
return view;
}
@RequestMapping("/leavemsg/save")
@Menu(type = "admin", subtype = "user")
public ModelAndView leavemsgsave(HttpServletRequest request, @Valid String appid, @Valid LeaveMsg msg) {
public ModelAndView leavemsgsave(HttpServletRequest request,
@Valid String appid,
@Valid LeaveMsg msg,
@Valid String skillId) {
if (StringUtils.isNotBlank(appid)) {
snsAccountRepository.findBySnsid(appid).ifPresent(p -> {
CousultInvite invite = inviteRepository.findBySnsaccountidAndOrgi(appid, MainContext.SYSTEM_ORGI);
snsAccountRepository.findBySnsid(appid).ifPresent(p -> {
CousultInvite invite = inviteRepository.findBySnsaccountidAndOrgi(appid, Constants.SYSTEM_ORGI);
// TODO 增加策略防止恶意刷消息
// List<LeaveMsg> msgList = leaveMsgRes.findByOrgiAndUserid(invite.getOrgi(), msg.getUserid());
// if(msg!=null && msgList.size() == 0){
if (msg != null) {
msg.setOrgi(invite.getOrgi());
msg.setSkill(skillId);
msg.setChannel(p);
msg.setSnsId(appid);
leaveMsgRes.save(msg);
@ -1170,7 +1181,7 @@ public class IMController extends Handler {
// 存储到本地硬盘
String id = processAttachmentFile(multipart,
fileid, logined.getOrgi(), logined.getId());
fileid, logined.getOrgi(), logined.getId());
upload = new UploadStatus("0", "/res/file.html?id=" + id);
String file = "/res/file.html?id=" + id;

View File

@ -1,104 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.apps;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Organization;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.OrganizationRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
@Controller
@RequestMapping("/apps/organization")
public class OrganizationController extends Handler {
@Autowired
private OrganizationRepository organizationRes;
@Autowired
private UserRepository userRes;
@RequestMapping("/add")
@Menu(type = "apps" , subtype = "organization")
public ModelAndView add(ModelMap map , HttpServletRequest request) {
return request(super.createRequestPageTempletResponse("/apps/organization/add"));
}
@RequestMapping("/save")
@Menu(type = "apps" , subtype = "organization")
public ModelAndView save(HttpServletRequest request ,@Valid Organization organization) throws NoSuchAlgorithmException, IOException {
if(StringUtils.isBlank(organization.getName())|| organization.getName().length()>100) {
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index?msg=max_illegal"));
}
organizationRes.save(organization) ;
User user = super.getUser(request);
if(user!=null) {
User userTemp = userRes.getOne(user.getId());
if(userTemp!=null&&StringUtils.isBlank(user.getOrgid())) {
userTemp.setOrgid(organization.getId());
userTemp.setOrgi(organization.getId());
userRes.save(userTemp);
super.setUser(request, userTemp);
}
}
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
//登录成功 判断是否进入多租户页面
SystemConfig systemConfig = MainUtils.getSystemConfig();
if(systemConfig!=null&&systemConfig.isEnabletneant()&&systemConfig.isTenantconsole()) {
view = request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
return view;
}
@RequestMapping("/edit")
@Menu(type = "apps" , subtype = "organization")
public ModelAndView edit(ModelMap map , HttpServletRequest request , @Valid String id) {
map.addAttribute("organization", organizationRes.findById(id)) ;
return request(super.createRequestPageTempletResponse("/apps/organization/edit"));
}
@RequestMapping("/update")
@Menu(type = "apps" , subtype = "organizationRes" , admin = true)
public ModelAndView update(HttpServletRequest request ,@Valid Organization organization) throws NoSuchAlgorithmException, IOException {
if(StringUtils.isBlank(organization.getName())|| organization.getName().length()>100) {
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index?msg=max_illegal"));
}
Organization temp = organizationRes.findById(organization.getId()) ;
if(organization!=null) {
organization.setCreatetime(temp.getCreatetime());
organizationRes.save(organization) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
}

View File

@ -282,7 +282,7 @@ public class QuickReplyController extends Handler {
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
@ -303,7 +303,7 @@ public class QuickReplyController extends Handler {
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
@ -324,7 +324,7 @@ public class QuickReplyController extends Handler {
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-QuickReply-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;

View File

@ -1,126 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.apps;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.SipTrunk;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.repository.ExtentionRepository;
import com.chatopera.cc.persistence.repository.SipTrunkRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import com.chatopera.cc.proxy.CallcenterOutboundProxy;
import com.chatopera.cc.util.CallCenterUtils;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.es.SearchTools;
import com.chatopera.cc.util.es.UKDataBean;
import com.chatopera.cc.util.freeswitch.model.CallCenterAgent;
import freemarker.template.TemplateException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
@Controller
@RequestMapping("/apps/callcenter")
public class SipTrunkController extends Handler {
@Autowired
private ExtentionRepository extentionRes;
@Autowired
private UserRepository userRepository;
@Autowired
private SipTrunkRepository sipTrunkRes;
@Autowired
private Cache cache;
@RequestMapping(value = "/siptrunk")
@Menu(type = "callcenter", subtype = "extention", access = true)
public ModelAndView detail(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String extno) throws IOException, TemplateException {
SipTrunk sipTrunk = CallCenterUtils.siptrunk(extno, sipTrunkRes, extentionRes);
map.addAttribute("siptrunk", sipTrunk);
response.setContentType("Content-type: text/plain; charset=utf-8");
return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/siptrunk"));
}
@RequestMapping(value = "/agent")
@Menu(type = "callcenter", subtype = "agent", access = true)
public ModelAndView agent(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String ani, @Valid String dest, @Valid String sip) throws IOException, TemplateException {
SipTrunk sipTrunk = CallCenterUtils.siptrunk(sip, sipTrunkRes);
map.addAttribute("siptrunk", sipTrunk);
String agent = null;
response.setContentType("Content-type: text/plain; charset=utf-8");
if (sipTrunk != null) {
PageImpl<UKDataBean> dataBeanList = SearchTools.namesearch(sipTrunk.getOrgi(), ani);
if (dataBeanList != null && dataBeanList.getContent().size() > 0) {
UKDataBean dataBean = dataBeanList.getContent().get(0);
if (dataBean.getValues().get(Constants.CSKEFU_SYSTEM_DIS_AGENT) != null) {
String disagent = (String) dataBean.getValues().get(Constants.CSKEFU_SYSTEM_DIS_AGENT);
/**
* 找到了 坐席
*/
CallCenterAgent callCenterAgent = cache.findOneCallCenterAgentByIdAndOrgi(disagent, sipTrunk.getOrgi());
if (callCenterAgent != null) {
/**
* 坐席在线
*/
agent = callCenterAgent.getExtno();
} else if (sipTrunk.isEnablecallagent()) {//坐席不在线
User user = userRepository.findById(disagent);
if (!StringUtils.isBlank(user.getMobile())) {
agent = user.getMobile();
}
}
} else {
/**
* 名单未分配 转给网关进来的任何一个坐席 从当前登录系统的 坐席中选取一个
*/
List<CallCenterAgent> agentList = CallcenterOutboundProxy.service(sipTrunk.getId());
if (agentList.size() > 0) {
CallCenterAgent callCenterAgent = agentList.get(0);
agent = callCenterAgent.getExtno();
} else if (!StringUtils.isBlank(sipTrunk.getNotready())) {
agent = sipTrunk.getNotready();
}
}
}
if (StringUtils.isBlank(agent) && !StringUtils.isBlank(sipTrunk.getNoname())) {
/**
* 未找到名单 SIPTrunk里选取一个 转移号码
*/
agent = sipTrunk.getNoname();
}
}
map.addAttribute("agent", agent);
return request(super.createRequestPageTempletResponse("/apps/business/callcenter/extention/agent"));
}
}

View File

@ -1,285 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.controller.apps;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.Cache;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.repository.*;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/apps/tenant")
public class TenantController extends Handler {
@Autowired
private TenantRepository tenantRes;
@Autowired
private OrgiSkillRelRepository orgiSkillRelRes;
@Autowired
private OrganRepository organRes;
@Autowired
private OrganizationRepository organizationRes;
@Autowired
private AgentUserRepository agentUserRepository;
@Autowired
private Cache cache;
@Value("${web.upload-path}")
private String path;
@RequestMapping("/index")
@Menu(type = "apps", subtype = "tenant")
public ModelAndView index(
ModelMap map, final HttpServletRequest request,
final @Valid String msg,
final @Valid String currentorgi,
final @Valid String currentname) throws IOException {
if (super.isEnabletneant()) {
// 系统管理员开启多租户访问
if (super.getUser(request).isAdmin()) {
map.addAttribute("tenantList", tenantRes.findByOrgid(super.getOrgid(request)));
} else {
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelRes.findBySkillidIn(
new ArrayList<>((super.getUser(request)).getAffiliates()));
List<Tenant> tenantList = null;
if (!orgiSkillRelList.isEmpty()) {
tenantList = new ArrayList<Tenant>();
for (OrgiSkillRel orgiSkillRel : orgiSkillRelList) {
Tenant t = tenantRes.findById(orgiSkillRel.getOrgi());
if (t != null) {
tenantList.add(t);
}
}
}
map.addAttribute("tenantList", tenantList);
}
} else {
map.addAttribute("tenantList", tenantRes.findById(super.getOrgi(request)));
}
map.addAttribute("organization", organizationRes.findById(super.getUser(request).getOrgid()));
map.addAttribute("msg", msg);
map.addAttribute("currentorgi", currentorgi);
if (currentname != null) {
map.addAttribute("currentname", URLDecoder.decode(currentname, "UTF-8"));
}
return request(super.createRequestPageTempletResponse("/apps/tenant/index"));
}
@RequestMapping("/add")
@Menu(type = "apps", subtype = "tenant")
public ModelAndView add(ModelMap map, HttpServletRequest request) {
if (super.isTenantshare()) {
map.addAttribute("isShowSkillGroups", true);
List<Organ> organList = organRes.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request), super.getOrgid(request));
map.addAttribute("skillGroups", organList);
}
return request(super.createRequestPageTempletResponse("/apps/tenant/add"));
}
@RequestMapping("/save")
@Menu(type = "apps", subtype = "tenant")
public ModelAndView save(HttpServletRequest request, @Valid Tenant tenant, @RequestParam(value = "tenantpic", required = false) MultipartFile tenantpic, @Valid String skills) throws NoSuchAlgorithmException, IOException {
Tenant tenanttemp = tenantRes.findByOrgidAndTenantname(super.getOrgid(request), tenant.getTenantname());
if (tenanttemp != null) {
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index.html?msg=tenantexist"));
}
tenantRes.save(tenant);
if (tenantpic != null && tenantpic.getOriginalFilename().lastIndexOf(".") > 0) {
File logoDir = new File(path, "tenantpic");
if (!logoDir.exists()) {
logoDir.mkdirs();
}
String fileName = "tenantpic/" + tenant.getId() + tenantpic.getOriginalFilename().substring(
tenantpic.getOriginalFilename().lastIndexOf("."));
FileCopyUtils.copy(tenantpic.getBytes(), new File(path, fileName));
tenant.setTenantlogo(fileName);
}
String tenantid = tenant.getId();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelRes.findByOrgi(tenantid);
orgiSkillRelRes.delete(orgiSkillRelList);
if (!StringUtils.isBlank(skills)) {
String[] skillsarray = skills.split(",");
for (String skill : skillsarray) {
OrgiSkillRel rel = new OrgiSkillRel();
rel.setOrgi(tenant.getId());
rel.setSkillid(skill);
rel.setCreater(super.getUser(request).getId());
rel.setCreatetime(new Date());
orgiSkillRelRes.save(rel);
}
}
if (!StringUtils.isBlank(super.getUser(request).getOrgid())) {
tenant.setOrgid(super.getUser(request).getOrgid());
} else {
tenant.setOrgid(MainContext.SYSTEM_ORGI);
}
tenantRes.save(tenant);
OnlineUserProxy.clean(tenantid);
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
@RequestMapping("/edit")
@Menu(type = "apps", subtype = "tenant")
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
if (super.isTenantshare()) {
map.addAttribute("isShowSkillGroups", true);
List<Organ> organList = organRes.findByOrgiAndOrgid(
super.getOrgiByTenantshare(request), super.getOrgid(request));
map.addAttribute("skillGroups", organList);
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelRes.findByOrgi(id);
map.addAttribute("orgiSkillRelList", orgiSkillRelList);
}
map.addAttribute("tenant", tenantRes.findById(id));
return request(super.createRequestPageTempletResponse("/apps/tenant/edit"));
}
@RequestMapping("/update")
@Menu(type = "apps", subtype = "tenant", admin = true)
public ModelAndView update(HttpServletRequest request, @Valid Tenant tenant, @RequestParam(value = "tenantpic", required = false) MultipartFile tenantpic, @Valid String skills) throws NoSuchAlgorithmException, IOException {
Tenant temp = tenantRes.findById(tenant.getId());
Tenant tenanttemp = tenantRes.findByOrgidAndTenantname(super.getOrgid(request), tenant.getTenantname());
if (temp != null && tenanttemp != null && !temp.getId().equals(tenanttemp.getId())) {
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index.html?msg=tenantexist"));
}
if (tenant != null) {
tenant.setCreatetime(temp.getCreatetime());
if (tenantpic != null && tenantpic.getOriginalFilename().lastIndexOf(".") > 0) {
File logoDir = new File(path, "tenantpic");
if (!logoDir.exists()) {
logoDir.mkdirs();
}
String fileName = "tenantpic/" + tenant.getId() + tenantpic.getOriginalFilename().substring(
tenantpic.getOriginalFilename().lastIndexOf("."));
FileCopyUtils.copy(tenantpic.getBytes(), new File(path, fileName));
tenant.setTenantlogo(fileName);
} else {
tenant.setTenantlogo(temp.getTenantlogo());
}
if (!StringUtils.isBlank(super.getUser(request).getOrgid())) {
tenant.setOrgid(super.getUser(request).getOrgid());
} else {
tenant.setOrgid(MainContext.SYSTEM_ORGI);
}
tenantRes.save(tenant);
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelRes.findByOrgi(tenant.getId());
orgiSkillRelRes.delete(orgiSkillRelList);
if (!StringUtils.isBlank(skills)) {
String[] skillsarray = skills.split(",");
for (String skill : skillsarray) {
OrgiSkillRel rel = new OrgiSkillRel();
rel.setOrgi(tenant.getId());
rel.setSkillid(skill);
rel.setCreater(super.getUser(request).getId());
rel.setCreatetime(new Date());
orgiSkillRelRes.save(rel);
}
}
OnlineUserProxy.clean(tenant.getId());
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
@RequestMapping("/delete")
@Menu(type = "apps", subtype = "tenant")
public ModelAndView delete(HttpServletRequest request, @Valid Tenant tenant) {
Tenant temp = tenantRes.findById(tenant.getId());
if (tenant != null) {
tenantRes.delete(temp);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index"));
}
@RequestMapping("/canswitch")
@Menu(type = "apps", subtype = "tenant")
public ModelAndView canswitch(HttpServletRequest request, @Valid Tenant tenant) throws UnsupportedEncodingException {
ModelAndView view = request(super.createRequestPageTempletResponse("redirect:/"));
AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
(super.getUser(request)).getId(), super.getOrgi(request));
if (agentStatus == null && cache.getInservAgentUsersSizeByAgentnoAndOrgi(
super.getUser(request).getId(), super.getOrgi(request)) == 0) {
Tenant temp = tenantRes.findById(tenant.getId());
if (temp != null) {
super.getUser(request).setOrgi(temp.getId());
}
return view;
}
if (agentStatus != null) {
if (tenant.getId().equals(agentStatus.getOrgi())) {
Tenant temp = tenantRes.findById(tenant.getId());
if (temp != null) {
super.getUser(request).setOrgi(temp.getId());
}
return view;
} else {
Tenant temp = tenantRes.findById(agentStatus.getOrgi());
return request(super.createRequestPageTempletResponse(
"redirect:/apps/tenant/index.html?msg=t0" + "&currentorgi=" + agentStatus.getOrgi() + "&currentname=" + URLEncoder.encode(
temp != null ? temp.getTenantname() : "", "UTF-8")));
}
}
AgentUser agentUser = agentUserRepository.findOneByAgentnoAndStatusAndOrgi(
super.getUser(request).getId(), MainContext.AgentUserStatusEnum.INSERVICE.toString(),
super.getOrgi(request));
if (agentUser != null) {
if (tenant.getId().equals(agentUser.getOrgi())) {
Tenant temp = tenantRes.findById(tenant.getId());
if (temp != null) {
super.getUser(request).setOrgi(temp.getId());
}
return view;
} else {
Tenant temp = tenantRes.findById(agentUser.getOrgi());
return request(super.createRequestPageTempletResponse(
"redirect:/apps/tenant/index.html?msg=t0" + "&currentorgi=" + agentUser.getOrgi() + "&currentname=" + URLEncoder.encode(
temp != null ? temp.getTenantname() : "", "UTF-8")));
}
}
return request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index.html?msg=t0"));
}
}

View File

@ -425,7 +425,7 @@ public class TopicController extends Handler{
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-XiaoE-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-XiaoE-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
@ -446,7 +446,7 @@ public class TopicController extends Handler{
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-XiaoE-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-XiaoE-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;

View File

@ -286,7 +286,7 @@ public class ReportController extends Handler{
values.add(MainUtils.transBean2Map(topic)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Report-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
@ -307,7 +307,7 @@ public class ReportController extends Handler{
values.add(MainUtils.transBean2Map(report)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Report-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
if(table!=null){
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;

View File

@ -16,20 +16,30 @@
*/
package com.chatopera.cc.controller.apps.service;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.AgentService;
import com.chatopera.cc.model.AgentServiceSummary;
import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.MetadataTable;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.persistence.repository.MetadataRepository;
import com.chatopera.cc.persistence.repository.ServiceSummaryRepository;
import com.chatopera.cc.persistence.repository.TagRepository;
import com.chatopera.cc.model.*;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.dsdata.export.ExcelExporterProcess;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.persistence.repository.ServiceSummaryRepository;
import com.chatopera.cc.persistence.repository.TagRepository;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -41,17 +51,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.chatopera.cc.persistence.repository.MetadataRepository;
import com.chatopera.cc.controller.Handler;
@Controller
@RequestMapping("/apps/agent/summary")
@ -71,7 +72,9 @@ public class AgentSummaryController extends Handler{
@Autowired
private ContactsRepository contactsRes ;
@Autowired
private OrganProxy organProxy;
/**
* 按条件查询
* @param map
@ -87,11 +90,15 @@ public class AgentSummaryController extends Handler{
@Menu(type = "agent" , subtype = "agentsummary" , access = false)
public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid final String begin , @Valid final String end ) {
final String orgi = super.getOrgi(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<AgentServiceSummary> page = serviceSummaryRes.findAll(new Specification<AgentServiceSummary>(){
@Override
public Predicate toPredicate(Root<AgentServiceSummary> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
List<Predicate> list = new ArrayList<Predicate>();
Expression<String> exp = root.<String>get("skill");
list.add(exp.in(organs.keySet()));
list.add(cb.equal(root.get("orgi").as(String.class),orgi)) ;
list.add(cb.equal(root.get("process").as(boolean.class), 0)) ;
list.add(cb.notEqual(root.get("channel").as(String.class), MainContext.ChannelType.PHONE.toString())) ;
@ -105,15 +112,15 @@ public class AgentSummaryController extends Handler{
} catch (ParseException e) {
e.printStackTrace();
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}}, new PageRequest(super.getP(request), super.getPs(request) , Sort.Direction.DESC, "createtime")) ;
map.addAttribute("summaryList", page) ;
map.addAttribute("begin", begin) ;
map.addAttribute("end", end) ;
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ;
return request(super.createAppsTempletResponse("/apps/service/summary/index"));
}
@ -161,7 +168,7 @@ public class AgentSummaryController extends Handler{
values.add(MainUtils.transBean2Map(event)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
@ -173,16 +180,17 @@ public class AgentSummaryController extends Handler{
@RequestMapping("/expall")
@Menu(type = "agent" , subtype = "agentsummary" , access = false)
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response) throws IOException {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi(
MainContext.ChannelType.PHONE.toString() , super.getOrgi(request) , new PageRequest(0, 10000));
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgiAndSkillIn(
MainContext.ChannelType.PHONE.toString() , super.getOrgi(request) , organs.keySet(),new PageRequest(0, 10000));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(AgentServiceSummary statusEvent : statusEventList){
values.add(MainUtils.transBean2Map(statusEvent)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
@ -220,7 +228,7 @@ public class AgentSummaryController extends Handler{
values.add(MainUtils.transBean2Map(summary)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
MetadataTable table = metadataRes.findByTablename("uk_servicesummary") ;

View File

@ -45,10 +45,7 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.nio.charset.CharacterCodingException;
@ -88,18 +85,9 @@ public class ChatServiceController extends Handler {
@Autowired
private LeaveMsgRepository leaveMsgRes;
@Autowired
private LeaveMsgProxy leaveMsgProxy;
@Autowired
private OrganRepository organRes;
@Autowired
private OrganRepository organ;
@Autowired
private UserRepository user;
@Autowired
private UserRepository userRes;
@ -109,6 +97,9 @@ public class ChatServiceController extends Handler {
@Autowired
private UserProxy userProxy;
@Autowired
private OrganProxy organProxy;
@Autowired
private Cache cache;
@ -118,13 +109,20 @@ public class ChatServiceController extends Handler {
@Autowired
private ACDMessageHelper acdMessageHelper;
@Autowired
private LeaveMsgProxy leaveMsgProxy;
@RequestMapping("/history/index")
@Menu(type = "service", subtype = "history", admin = true)
public ModelAndView index(ModelMap map, HttpServletRequest request, final String username, final String channel, final String servicetype, final String allocation, final String servicetimetype, final String begin, final String end) {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<AgentService> page = agentServiceRes.findAll(new Specification<AgentService>() {
@Override
public Predicate toPredicate(Root<AgentService> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
Expression<String> exp = root.<String>get("skill");
list.add(exp.in(organs.keySet()));
if (StringUtils.isNotBlank(username)) {
list.add(cb.equal(root.get("username").as(String.class), username));
}
@ -162,8 +160,8 @@ public class ChatServiceController extends Handler {
map.put("allocation", allocation);
map.put("begin", begin);
map.put("end", end);
map.put("deptlist", organ.findByOrgi(super.getOrgi(request)));
map.put("userlist", user.findByOrgiAndDatastatus(super.getOrgi(request), false));
map.put("deptlist", organs.values());
map.put("userlist", userProxy.findUserInOrgans(organs.keySet()));
return request(super.createAppsTempletResponse("/apps/service/history/index"));
}
@ -171,40 +169,45 @@ public class ChatServiceController extends Handler {
@RequestMapping("/current/index")
@Menu(type = "service", subtype = "current", admin = true)
public ModelAndView current(ModelMap map, HttpServletRequest request) {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
map.put(
"agentServiceList", agentServiceRes.findByOrgiAndStatus(
"agentServiceList", agentServiceRes.findByOrgiAndStatusAndAgentskillIn(
super.getOrgi(request),
MainContext.AgentUserStatusEnum.INSERVICE.toString(),
organs.keySet(),
new PageRequest(
super.getP(request),
super.getPs(request), Direction.DESC,
"createtime")));
return request(super.createAppsTempletResponse("/apps/service/current/index"));
}
@RequestMapping("/current/trans")
@Menu(type = "service", subtype = "current", admin = true)
public ModelAndView trans(ModelMap map, HttpServletRequest request, @Valid String id) {
Organ targetOrgan = super.getOrgan(request);
final String orgi = super.getOrgi(request);
final User logined = super.getUser(request);
Map<String, Organ> ownOrgans = organProxy.findAllOrganByParentAndOrgi(targetOrgan, super.getOrgi(request));
if (StringUtils.isNotBlank(id)) {
AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request));
List<Organ> skillGroups = OnlineUserProxy.organ(super.getOrgi(request), true);
Set<String> organs = logined.getOrgans().keySet();
String currentOrgan = organs.size() > 0 ? (new ArrayList<>(organs)).get(0) : null;
List<Organ> skillGroups = organRes.findByOrgiAndIdInAndSkill(super.getOrgi(request), ownOrgans.keySet(), true);
Set<String> organs = ownOrgans.keySet();
String currentOrgan = agentService.getSkill();
if (StringUtils.isBlank(currentOrgan)) {
if (!skillGroups.isEmpty()) {
currentOrgan = skillGroups.get(0).getId();
}
}
List<AgentStatus> agentStatusList = cache.getAgentStatusBySkillAndOrgi(null, super.getOrgi(request));
final Map<String, AgentStatus> agentStatusMap = cache.findAllReadyAgentStatusByOrgi(orgi);
List<String> usersids = new ArrayList<String>();
if (!agentStatusList.isEmpty()) {
for (AgentStatus agentStatus : agentStatusList) {
if (agentStatus != null) {
usersids.add(agentStatus.getAgentno());
}
for (final String o : agentStatusMap.keySet()) {
if (!StringUtils.equals(o, agentService.getAgentno())) {
usersids.add(o);
}
}
List<User> userList = userRes.findAll(usersids);
@ -399,8 +402,10 @@ public class ChatServiceController extends Handler {
@RequestMapping("/quene/index")
@Menu(type = "service", subtype = "filter", admin = true)
public ModelAndView quene(ModelMap map, HttpServletRequest request) {
Page<AgentUser> agentUserList = agentUserRes.findByOrgiAndStatus(
super.getOrgi(request), MainContext.AgentUserStatusEnum.INQUENE.toString(),
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<AgentUser> agentUserList = agentUserRes.findByOrgiAndStatusAndSkillIn(
super.getOrgi(request), MainContext.AgentUserStatusEnum.INQUENE.toString(), organs.keySet(),
new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime"));
List<String> skillGroups = new ArrayList<String>();
for (AgentUser agentUser : agentUserList.getContent()) {
@ -423,16 +428,57 @@ public class ChatServiceController extends Handler {
}
}
map.put("agentUserList", agentUserList);
return request(super.createAppsTempletResponse("/apps/service/quene/index"));
}
@RequestMapping("/quene/clean")
@Menu(type = "service", subtype = "queneclean", admin = true)
public ModelAndView clean(ModelMap map, HttpServletRequest request, @Valid String id) {
@RequestMapping("/quene/transfer")
@Menu(type = "service", subtype = "quenetransfer", admin = true)
public ModelAndView transfer(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String skillid) {
Organ targetOrgan = super.getOrgan(request);
Map<String, Organ> ownOrgans = organProxy.findAllOrganByParentAndOrgi(targetOrgan, super.getOrgi(request));
if (StringUtils.isNotBlank(id)) {
List<Organ> skillGroups = organRes.findByOrgiAndIdInAndSkill(super.getOrgi(request), ownOrgans.keySet(), true);
Set<String> organs = ownOrgans.keySet();
String currentOrgan = organs.size() > 0 ? (new ArrayList<>(organs)).get(0) : null;
if (StringUtils.isBlank(currentOrgan)) {
if (!skillGroups.isEmpty()) {
currentOrgan = skillGroups.get(0).getId();
}
}
List<AgentStatus> agentStatusList = cache.getAgentStatusBySkillAndOrgi(null, super.getOrgi(request));
List<String> usersids = new ArrayList<String>();
if (!agentStatusList.isEmpty()) {
for (AgentStatus agentStatus : agentStatusList) {
if (agentStatus != null) {
usersids.add(agentStatus.getAgentno());
}
}
}
List<User> userList = userRes.findAll(usersids);
for (User user : userList) {
user.setAgentStatus(cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), super.getOrgi(request)));
userProxy.attachOrgansPropertiesForUser(user);
}
map.put("id", id);
map.put("skillid", skillid);
map.addAttribute("userList", userList);
map.addAttribute("skillGroups", skillGroups);
map.addAttribute("currentorgan", currentOrgan);
}
return request(super.createRequestPageTempletResponse("/apps/service/quene/transfer"));
}
@RequestMapping("/quene/transfer/save")
@Menu(type = "service", subtype = "quenetransfer", admin = true)
public ModelAndView transferSave(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String skillid) {
AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request));
if (agentUser != null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) {
agentUser.setAgentno(null);
agentUser.setSkill(null);
agentUser.setSkill(skillid);
agentUserRes.save(agentUser);
ACDComposeContext ctx = acdMessageHelper.getComposeContextWithAgentUser(
agentUser, false, MainContext.ChatInitiatorType.USER.toString());
@ -463,13 +509,18 @@ public class ChatServiceController extends Handler {
@RequestMapping("/agent/index")
@Menu(type = "service", subtype = "onlineagent", admin = true)
public ModelAndView agent(ModelMap map, HttpServletRequest request) {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
final Map<String, AgentStatus> ass = cache.findAllAgentStatusByOrgi(super.getOrgi(request));
List<AgentStatus> lis = new ArrayList<>();
for (final Map.Entry<String, AgentStatus> as : ass.entrySet()) {
lis.add(as.getValue());
List<User> users = userProxy.findUserInOrgans(organs.keySet());
if (users != null) {
for (User us : users) {
if (ass.containsKey(us.getId())) {
lis.add(ass.get(us.getId()));
}
}
}
map.put("agentStatusList", lis);
return request(super.createAppsTempletResponse("/apps/service/agent/index"));
}
@ -508,33 +559,21 @@ public class ChatServiceController extends Handler {
@RequestMapping("/user/index")
@Menu(type = "service", subtype = "userlist", admin = true)
public ModelAndView user(ModelMap map, HttpServletRequest request) {
Page<User> userList;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<User> userList = userProxy.findUserInOrgans(organs.keySet(), new PageRequest(super.getP(request), super.getPs(request),
Direction.DESC, "createtime"));
Map<String, Boolean> onlines = new HashMap<>();
if (userList != null) {
for (User user : userList.getContent()) {
if (cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), super.getOrgi(request)) != null) {
onlines.put(user.getId(), true);
} else {
onlines.put(user.getId(), false);
}
}
userList = userProxy.findByOrganInAndAgentAndDatastatus(
organIdList, true, false, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC,
"createtime"));
} else {
userList = userRes.findByOrgiAndAgentAndDatastatus(
super.getOrgi(request), true, false, new PageRequest(super.getP(request), super.getPs(request),
Direction.DESC, "createtime"));
}
Map<String, Boolean> onlines = new HashMap<>();
for (User user : userList.getContent()) {
if (cache.findOneAgentStatusByAgentnoAndOrig(user.getId(), super.getOrgi(request)) != null) {
onlines.put(user.getId(), true);
} else {
onlines.put(user.getId(), false);
}
}
map.put("userList", userList);
map.put("onlines", onlines);
return request(super.createAppsTempletResponse("/apps/service/user/index"));
@ -543,9 +582,12 @@ public class ChatServiceController extends Handler {
@RequestMapping("/leavemsg/index")
@Menu(type = "service", subtype = "leavemsg", admin = true)
public ModelAndView leavemsg(ModelMap map, HttpServletRequest request) {
Page<LeaveMsg> leaveMsgs = leaveMsgRes.findByOrgi(
super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Direction.DESC,
"createtime"));
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<LeaveMsg> leaveMsgs = leaveMsgRes.findBySkillAndOrgi(organs.keySet(), super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request),
Direction.DESC, "createtime"));
logger.info("[leavemsg] current organ {}, find message size {}", currentOrgan.getId(), leaveMsgs.getSize());
for (final LeaveMsg l : leaveMsgs) {
leaveMsgProxy.resolveChannelBySnsid(l);
}

View File

@ -18,7 +18,9 @@ package com.chatopera.cc.controller.apps.service;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.AgentService;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -30,18 +32,23 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
@Controller
@RequestMapping("/service")
public class CommentController extends Handler{
@Autowired
private AgentServiceRepository agentServiceRes ;
@Autowired
private OrganProxy organProxy;
@RequestMapping("/comment/index")
@Menu(type = "service" , subtype = "comment" , admin= true)
public ModelAndView index(ModelMap map , HttpServletRequest request , String userid , String agentservice , @Valid String channel) {
Page<AgentService> agentServiceList = agentServiceRes.findByOrgiAndSatisfaction(super.getOrgi(request) , true ,new PageRequest(super.getP(request), super.getPs(request))) ;
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<AgentService> agentServiceList = agentServiceRes.findByOrgiAndSatisfactionAndSkillIn(super.getOrgi(request) , true ,organs.keySet(),new PageRequest(super.getP(request), super.getPs(request))) ;
map.addAttribute("serviceList", agentServiceList) ;
return request(super.createAppsTempletResponse("/apps/service/comment/index"));
}

View File

@ -140,10 +140,11 @@ public class OnlineUserController extends Handler {
userid, orgi).ifPresent(p -> {
map.put("contacts", contactsRes.findOne(p.getContactsid()));
});
map.put(
"tags",
tagRes.findByOrgiAndTagtype(orgi, MainContext.ModelType.USER.toString()));
AgentService service = agentServiceRes.findByIdAndOrgi(agentservice, orgi);
if (service != null) {
map.addAttribute(
"tags", tagRes.findByOrgiAndTagtypeAndSkill(orgi, MainContext.ModelType.USER.toString(), service.getSkill()));
}
map.put(
"summaryTags",
tagRes.findByOrgiAndTagtype(orgi, MainContext.ModelType.SUMMARY.toString()));

View File

@ -19,15 +19,13 @@ package com.chatopera.cc.controller.apps.service;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.AgentService;
import com.chatopera.cc.model.AgentServiceSummary;
import com.chatopera.cc.model.Contacts;
import com.chatopera.cc.model.MetadataTable;
import com.chatopera.cc.model.*;
import com.chatopera.cc.persistence.es.ContactsRepository;
import com.chatopera.cc.persistence.repository.AgentServiceRepository;
import com.chatopera.cc.persistence.repository.MetadataRepository;
import com.chatopera.cc.persistence.repository.ServiceSummaryRepository;
import com.chatopera.cc.persistence.repository.TagRepository;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.dsdata.export.ExcelExporterProcess;
import org.apache.commons.lang.StringUtils;
@ -41,10 +39,7 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@ -54,192 +49,204 @@ import java.util.*;
@Controller
@RequestMapping("/apps/agent/processed")
public class ProcessedSummaryController extends Handler{
@Autowired
private ServiceSummaryRepository serviceSummaryRes ;
@Autowired
private MetadataRepository metadataRes ;
@Autowired
private AgentServiceRepository agentServiceRes ;
@Autowired
private TagRepository tagRes ;
@Autowired
private ContactsRepository contactsRes ;
/**
* 按条件查询
* @param map
* @param request
* @param ani
* @param called
* @param begin
* @param end
* @param direction
* @return
*/
@RequestMapping(value = "/index")
@Menu(type = "agent" , subtype = "processed" , access = false)
public ModelAndView index(ModelMap map , HttpServletRequest request ,@Valid final String ani , @Valid final String called , @Valid final String begin , @Valid final String end , @Valid final String direction) {
final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll(new Specification<AgentServiceSummary>(){
@Override
public Predicate toPredicate(Root<AgentServiceSummary> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
list.add(cb.equal(root.get("process").as(boolean.class), 1)) ;
list.add(cb.equal(root.get("orgi").as(String.class),orgi)) ;
list.add(cb.notEqual(root.get("channel").as(String.class), MainContext.ChannelType.PHONE.toString())) ;
if(!StringUtils.isBlank(ani)){
list.add(cb.equal(root.get("ani").as(String.class), ani)) ;
}
if(!StringUtils.isBlank(called)){
list.add(cb.equal(root.get("called").as(String.class), called)) ;
}
try {
if(!StringUtils.isBlank(begin) && begin.matches("[\\d]{4}-[\\d]{2}-[\\d]{2}")) {
list.add(cb.greaterThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.simpleDateFormat.parse(begin)));
}
if(!StringUtils.isBlank(end) && end.matches("[\\d]{4}-[\\d]{2}-[\\d]{2}")){
list.add(cb.lessThanOrEqualTo(root.get("createtime").as(Date.class),MainUtils.dateFormate.parse(end + " 23:59:59")));
}
} catch (Exception e) {
e.printStackTrace();
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}}, new PageRequest(super.getP(request), super.getPs(request) , Sort.Direction.DESC, "createtime")) ;
map.addAttribute("summaryList", page) ;
map.addAttribute("ani", ani) ;
map.addAttribute("called", called) ;
map.addAttribute("begin", begin) ;
map.addAttribute("end", end) ;
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ;
return request(super.createAppsTempletResponse("/apps/service/processed/index"));
public class ProcessedSummaryController extends Handler {
@Autowired
private ServiceSummaryRepository serviceSummaryRes;
@Autowired
private MetadataRepository metadataRes;
@Autowired
private AgentServiceRepository agentServiceRes;
@Autowired
private TagRepository tagRes;
@Autowired
private ContactsRepository contactsRes;
@Autowired
private OrganProxy organProxy;
/**
* 按条件查询
*
* @param map
* @param request
* @param ani
* @param called
* @param begin
* @param end
* @param direction
* @return
*/
@RequestMapping(value = "/index")
@Menu(type = "agent", subtype = "processed", access = false)
public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid final String ani, @Valid final String called, @Valid final String begin, @Valid final String end, @Valid final String direction) {
final String orgi = super.getOrgi(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Page<AgentServiceSummary> page = serviceSummaryRes.findAll(new Specification<AgentServiceSummary>() {
@Override
public Predicate toPredicate(Root<AgentServiceSummary> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
Expression<String> exp = root.<String>get("skill");
list.add(exp.in(organs.keySet()));
list.add(cb.equal(root.get("process").as(boolean.class), 1));
list.add(cb.equal(root.get("orgi").as(String.class), orgi));
list.add(cb.notEqual(root.get("channel").as(String.class), MainContext.ChannelType.PHONE.toString()));
if (!StringUtils.isBlank(ani)) {
list.add(cb.equal(root.get("ani").as(String.class), ani));
}
if (!StringUtils.isBlank(called)) {
list.add(cb.equal(root.get("called").as(String.class), called));
}
try {
if (!StringUtils.isBlank(begin) && begin.matches("[\\d]{4}-[\\d]{2}-[\\d]{2}")) {
list.add(cb.greaterThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.simpleDateFormat.parse(begin)));
}
if (!StringUtils.isBlank(end) && end.matches("[\\d]{4}-[\\d]{2}-[\\d]{2}")) {
list.add(cb.lessThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.dateFormate.parse(end + " 23:59:59")));
}
} catch (Exception e) {
e.printStackTrace();
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}, new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
map.addAttribute("summaryList", page);
map.addAttribute("ani", ani);
map.addAttribute("called", called);
map.addAttribute("begin", begin);
map.addAttribute("end", end);
map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString()));
return request(super.createAppsTempletResponse("/apps/service/processed/index"));
}
@RequestMapping(value = "/process")
@Menu(type = "agent" , subtype = "processed" , access = false)
public ModelAndView process(ModelMap map , HttpServletRequest request , @Valid final String id) {
AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request)) ;
map.addAttribute("summary",summary) ;
map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ;
if(summary!=null && !StringUtils.isBlank(summary.getAgentserviceid())){
AgentService service = agentServiceRes.findByIdAndOrgi(summary.getAgentserviceid(), super.getOrgi(request)) ;
map.addAttribute("service",service) ;
if(!StringUtils.isBlank(summary.getContactsid())){
Contacts contacts = contactsRes.findOne(summary.getContactsid()) ;
map.addAttribute("contacts",contacts) ;
}
}
return request(super.createRequestPageTempletResponse("/apps/service/processed/process"));
}
@RequestMapping(value = "/save")
@Menu(type = "agent" , subtype = "processed" , access = false)
public ModelAndView save(ModelMap map , HttpServletRequest request , @Valid final AgentServiceSummary summary) {
AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request)) ;
if(oldSummary!=null){
oldSummary.setProcess(true);
oldSummary.setUpdatetime(new Date());
oldSummary.setUpdateuser(super.getUser(request).getId());
oldSummary.setProcessmemo(summary.getProcessmemo());
serviceSummaryRes.save(oldSummary) ;
}
return request(super.createRequestPageTempletResponse("redirect:/apps/agent/processed/index.html"));
}
@RequestMapping("/expids")
@Menu(type = "agent" , subtype = "processed" , access = false)
public void expids(ModelMap map , HttpServletRequest request , HttpServletResponse response , @Valid String[] ids) throws IOException {
if(ids!=null && ids.length > 0){
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAll(Arrays.asList(ids)) ;
MetadataTable table = metadataRes.findByTablename("uk_servicesummary") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(AgentServiceSummary event : statusEventList){
values.add(MainUtils.transBean2Map(event)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
}
return ;
}
@RequestMapping("/expall")
@Menu(type = "agent" , subtype = "processed" , access = false)
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response) throws IOException {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgi(
MainContext.ChannelType.PHONE.toString() , super.getOrgi(request) , new PageRequest(0, 10000));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary") ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(AgentServiceSummary statusEvent : statusEventList){
values.add(MainUtils.transBean2Map(statusEvent)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
return ;
}
@RequestMapping("/expsearch")
@Menu(type = "agent" , subtype = "processed" , access = false)
public void expall(ModelMap map , HttpServletRequest request , HttpServletResponse response,@Valid final String ani , @Valid final String called , @Valid final String begin , @Valid final String end , @Valid final String direction) throws IOException {
final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll(new Specification<AgentServiceSummary>(){
@Override
public Predicate toPredicate(Root<AgentServiceSummary> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
list.add(cb.equal(root.get("process").as(boolean.class), 1)) ;
list.add(cb.equal(root.get("orgi").as(String.class),orgi)) ;
if(!StringUtils.isBlank(ani)){
list.add(cb.equal(root.get("ani").as(String.class), ani)) ;
}
if(!StringUtils.isBlank(called)){
list.add(cb.equal(root.get("called").as(String.class), called)) ;
}
try {
if(!StringUtils.isBlank(begin) && begin.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")){
list.add(cb.greaterThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.dateFormate.parse(begin))) ;
}
if(!StringUtils.isBlank(end) && end.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")){
list.add(cb.lessThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.dateFormate.parse(end))) ;
}
} catch (Exception e) {
e.printStackTrace();
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}}, new PageRequest(0, 10000 , Sort.Direction.DESC, "createtime")) ;
List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
for(AgentServiceSummary summary : page){
values.add(MainUtils.transBean2Map(summary)) ;
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Summary-History-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls");
MetadataTable table = metadataRes.findByTablename("uk_servicesummary") ;
ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ;
excelProcess.process();
return ;
}
@RequestMapping(value = "/process")
@Menu(type = "agent", subtype = "processed", access = false)
public ModelAndView process(ModelMap map, HttpServletRequest request, @Valid final String id) {
AgentServiceSummary summary = serviceSummaryRes.findByIdAndOrgi(id, super.getOrgi(request));
map.addAttribute("summary", summary);
map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString()));
if (summary != null && !StringUtils.isBlank(summary.getAgentserviceid())) {
AgentService service = agentServiceRes.findByIdAndOrgi(summary.getAgentserviceid(), super.getOrgi(request));
map.addAttribute("service", service);
if (!StringUtils.isBlank(summary.getContactsid())) {
Contacts contacts = contactsRes.findOne(summary.getContactsid());
map.addAttribute("contacts", contacts);
}
}
return request(super.createRequestPageTempletResponse("/apps/service/processed/process"));
}
@RequestMapping(value = "/save")
@Menu(type = "agent", subtype = "processed", access = false)
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid final AgentServiceSummary summary) {
AgentServiceSummary oldSummary = serviceSummaryRes.findByIdAndOrgi(summary.getId(), super.getOrgi(request));
if (oldSummary != null) {
oldSummary.setProcess(true);
oldSummary.setUpdatetime(new Date());
oldSummary.setUpdateuser(super.getUser(request).getId());
oldSummary.setProcessmemo(summary.getProcessmemo());
serviceSummaryRes.save(oldSummary);
}
return request(super.createRequestPageTempletResponse("redirect:/apps/agent/processed/index.html"));
}
@RequestMapping("/expids")
@Menu(type = "agent", subtype = "processed", access = false)
public void expids(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String[] ids) throws IOException {
if (ids != null && ids.length > 0) {
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findAll(Arrays.asList(ids));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
for (AgentServiceSummary event : statusEventList) {
values.add(MainUtils.transBean2Map(event));
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Summary-History-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
excelProcess.process();
}
return;
}
@RequestMapping("/expall")
@Menu(type = "agent", subtype = "processed", access = false)
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws IOException {
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Iterable<AgentServiceSummary> statusEventList = serviceSummaryRes.findByChannelNotAndOrgiAndProcessTrueAndSkillIn(
MainContext.ChannelType.PHONE.toString(), super.getOrgi(request), organs.keySet(), new PageRequest(0, 10000));
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
for (AgentServiceSummary statusEvent : statusEventList) {
values.add(MainUtils.transBean2Map(statusEvent));
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Summary-History-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
excelProcess.process();
return;
}
@RequestMapping("/expsearch")
@Menu(type = "agent", subtype = "processed", access = false)
public void expall(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid final String ani, @Valid final String called, @Valid final String begin, @Valid final String end, @Valid final String direction) throws IOException {
final String orgi = super.getOrgi(request);
Page<AgentServiceSummary> page = serviceSummaryRes.findAll(new Specification<AgentServiceSummary>() {
@Override
public Predicate toPredicate(Root<AgentServiceSummary> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
list.add(cb.equal(root.get("process").as(boolean.class), 1));
list.add(cb.equal(root.get("orgi").as(String.class), orgi));
if (!StringUtils.isBlank(ani)) {
list.add(cb.equal(root.get("ani").as(String.class), ani));
}
if (!StringUtils.isBlank(called)) {
list.add(cb.equal(root.get("called").as(String.class), called));
}
try {
if (!StringUtils.isBlank(begin) && begin.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")) {
list.add(cb.greaterThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.dateFormate.parse(begin)));
}
if (!StringUtils.isBlank(end) && end.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")) {
list.add(cb.lessThanOrEqualTo(root.get("createtime").as(Date.class), MainUtils.dateFormate.parse(end)));
}
} catch (Exception e) {
e.printStackTrace();
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}, new PageRequest(0, 10000, Sort.Direction.DESC, "createtime"));
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
for (AgentServiceSummary summary : page) {
values.add(MainUtils.transBean2Map(summary));
}
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Summary-History-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
MetadataTable table = metadataRes.findByTablename("uk_servicesummary");
ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream());
excelProcess.process();
return;
}
}

View File

@ -17,13 +17,14 @@
package com.chatopera.cc.controller.apps.service;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainUtils;
import com.chatopera.cc.controller.Handler;
import com.chatopera.cc.model.Dict;
import com.chatopera.cc.model.Organ;
import com.chatopera.cc.model.SysDic;
import com.chatopera.cc.persistence.repository.CubeService;
import com.chatopera.cc.persistence.repository.DataSourceService;
import com.chatopera.cc.proxy.OnlineUserProxy;
import com.chatopera.cc.proxy.OrganProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.bi.ReportData;
import com.chatopera.cc.util.bi.UKExcelUtil;
@ -42,9 +43,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping("/service")
@ -58,6 +59,13 @@ public class StatsController extends Handler {
@Autowired
private DataSourceService dataSource;
@Autowired
private OrganProxy organProxy;
@Autowired
private UserProxy userProxy;
@RequestMapping("/stats/coment")
@Menu(type = "service", subtype = "statcoment", admin = true)
public ModelAndView statcoment(ModelMap map, HttpServletRequest request,
@ -66,8 +74,22 @@ public class StatsController extends Handler {
@Valid String begin,
@Valid String end) throws Exception {
logger.info("[statcoment] agent {}, skill {}, begin {}, end {}", agent, skill, begin, end);
Map<String, Object> mapR = MainUtils.getRequestParam(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Map<String, Object> mapR = new HashMap<>();
mapR.put("orgi", super.getOrgi(request));
mapR.put("begin", begin);
mapR.put("agent", agent);
mapR.put("end", end);
if (StringUtils.isNotBlank(skill)) {
map.addAttribute("skill", skill);
map.addAttribute("agentList", userProxy.findUserInOrgans(Arrays.asList(skill)));
mapR.put("skill", "'" + skill + "'");
} else {
map.addAttribute("agentList", userProxy.findUserInOrgans(organs.keySet()));
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
ReportData reportData = new CubeService("coment.xml", path, dataSource, mapR).execute("SELECT [comment].[满意度].members on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [满意度]");
List<SysDic> dicList = Dict.getInstance().getDic(Constants.CSKEFU_SYSTEM_COMMENT_DIC);
@ -96,11 +118,7 @@ public class StatsController extends Handler {
/***
* 查询 技能组 缓存
*/
map.addAttribute("skillGroups", OnlineUserProxy.organ(super.getOrgi(request), true));
/**
* 查询坐席 缓存
*/
map.addAttribute("agentList", OnlineUserProxy.agents(super.getOrgi(request)));
map.addAttribute("skillGroups", organs.values());
return request(super.createAppsTempletResponse("/apps/service/stats/coment"));
}
@ -108,7 +126,17 @@ public class StatsController extends Handler {
@RequestMapping("/stats/coment/exp")
@Menu(type = "service", subtype = "statcoment", admin = true)
public void statcomentexp(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String agent, @Valid String skill, @Valid String begin, @Valid String end) throws Exception {
Map<String, Object> mapR = MainUtils.getRequestParam(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Map<String, Object> mapR = new HashMap<>();
mapR.put("begin", begin);
mapR.put("agent", agent);
mapR.put("end", end);
if (StringUtils.isNotBlank(skill)) {
mapR.put("skill", "'" + skill + "'");
} else {
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
mapR.put("orgi", super.getOrgi(request));
ReportData reportData = new CubeService("coment.xml", path, dataSource, mapR).execute("SELECT [comment].[满意度].members on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [满意度]");
@ -121,7 +149,7 @@ public class StatsController extends Handler {
}
}
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Report-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
new UKExcelUtil(reportData, response.getOutputStream(), "满意度统计").createFile();
return;
@ -130,7 +158,20 @@ public class StatsController extends Handler {
@RequestMapping("/stats/agent")
@Menu(type = "service", subtype = "statagent", admin = true)
public ModelAndView statagent(ModelMap map, HttpServletRequest request, @Valid String agent, @Valid String skill, @Valid String begin, @Valid String end) throws Exception {
Map<String, Object> mapR = MainUtils.getRequestParam(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Map<String, Object> mapR = new HashMap<>();
mapR.put("begin", begin);
mapR.put("agent", agent);
mapR.put("end", end);
if (StringUtils.isNotBlank(skill)) {
map.addAttribute("skill", skill);
map.addAttribute("agentList", userProxy.findUserInOrgans(Arrays.asList(skill)));
mapR.put("skill", "'" + skill + "'");
} else {
map.addAttribute("agentList", userProxy.findUserInOrgans(organs.keySet()));
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
mapR.put("orgi", super.getOrgi(request));
ReportData reportData = new CubeService("consult.xml", path, dataSource, mapR).execute("SELECT {[Measures].[咨询数量],[Measures].[平均等待时长(秒)],[Measures].[平均咨询时长(秒)]} on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [咨询]");
map.addAttribute("reportData", reportData);
@ -138,9 +179,6 @@ public class StatsController extends Handler {
if (StringUtils.isNotBlank(agent)) {
map.addAttribute("agent", agent);
}
if (StringUtils.isNotBlank(skill)) {
map.addAttribute("skill", skill);
}
if (StringUtils.isNotBlank(begin)) {
map.addAttribute("begin", begin);
}
@ -150,24 +188,28 @@ public class StatsController extends Handler {
/***
* 查询 技能组 缓存
*/
map.addAttribute("skillGroups", OnlineUserProxy.organ(super.getOrgi(request), true));
/**
* 查询坐席 缓存
*/
map.addAttribute("agentList", OnlineUserProxy.agents(super.getOrgi(request)));
map.addAttribute("skillGroups", organs.values());
return request(super.createAppsTempletResponse("/apps/service/stats/consult"));
}
@RequestMapping("/stats/agent/exp")
@Menu(type = "service", subtype = "statagent", admin = true)
public void statagentexp(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String agent, @Valid String skill, @Valid String begin, @Valid String end) throws Exception {
Map<String, Object> mapR = MainUtils.getRequestParam(request);
Organ currentOrgan = super.getOrgan(request);
Map<String, Organ> organs = organProxy.findAllOrganByParentAndOrgi(currentOrgan, super.getOrgi(request));
Map<String, Object> mapR = new HashMap<>();
mapR.put("begin", begin);
mapR.put("agent", agent);
mapR.put("end", end);
if (StringUtils.isNotBlank(skill)) {
mapR.put("skill", "'" + skill + "'");
} else {
mapR.put("skill", organs.keySet().stream().map(p -> "'" + p + "'").collect(Collectors.joining(",")));
}
mapR.put("orgi", super.getOrgi(request));
ReportData reportData = new CubeService("consult.xml", path, dataSource, mapR).execute("SELECT {[Measures].[咨询数量],[Measures].[平均等待时长(秒)],[Measures].[平均咨询时长(秒)]} on columns , NonEmptyCrossJoin([time].[日期].members , NonEmptyCrossJoin([skill].[技能组].members,[agent].[坐席].members)) on rows FROM [咨询]");
response.setHeader("content-disposition", "attachment;filename=CSKeFu-Report-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
response.setHeader("content-disposition", "attachment;filename=UCKeFu-Report-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls");
new UKExcelUtil(reportData, response.getOutputStream(), "客服坐席统计").createFile();
return;
}
}

View File

@ -38,7 +38,7 @@ public class QuickReplyResourceController extends Handler{
if(q==null){
q = "" ;
}
map.addAttribute("quickReplyList", OnlineUserProxy.search(q, super.getOrgi(request), super.getUser(request))) ;
// map.addAttribute("quickReplyList", OnlineUserProxy.search(q, super.getOrgi(request), super.getUser(request))) ;
return request(super.createRequestPageTempletResponse("/public/quickreply"));
}
}

View File

@ -83,20 +83,7 @@ public class UsersResourceController extends Handler {
}
private List<User> getUsers(HttpServletRequest request) {
List<User> list = null;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
list = userProxy.findByOrganInAndDatastatus(organIdList, false);
} else {
list = userRes.findByOrgiAndDatastatus(super.getOrgi(request), false);
}
return list;
return userRes.findByOrgiAndDatastatus(super.getOrgi(request), false);
}
/**
@ -110,19 +97,7 @@ public class UsersResourceController extends Handler {
if (q == null) {
q = "";
}
Page<User> list = null;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
list = userProxy.findByOrganInAndDatastatusAndUsernameLike(organIdList, false, "%" + q + "%", new PageRequest(0, 10));
} else {
list = userRes.findByDatastatusAndOrgiAndOrgidAndUsernameLike(false, super.getOrgi(request), super.getOrgid(request), "%" + q + "%", new PageRequest(0, 10));
}
Page<User> list = userRes.findByDatastatusAndOrgiAndUsernameLike(false, super.getOrgi(), "%" + q + "%", new PageRequest(0, 10));
return list;
}
@ -133,19 +108,7 @@ public class UsersResourceController extends Handler {
* @return
*/
private List<Organ> getOrgans(HttpServletRequest request) {
List<Organ> list = null;
if (super.isTenantshare()) {
List<String> organIdList = new ArrayList<>();
List<OrgiSkillRel> orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request));
if (!orgiSkillRelList.isEmpty()) {
for (OrgiSkillRel rel : orgiSkillRelList) {
organIdList.add(rel.getSkillid());
}
}
list = organRes.findByIdInAndSkill(organIdList, true);
} else {
list = organRes.findByOrgiAndSkillAndOrgid(super.getOrgi(request), true, super.getOrgid(request));
}
List<Organ> list = organRes.findByOrgiAndSkill(super.getOrgi(request), true);
return list;
}
}

View File

@ -60,7 +60,8 @@ public class LogIntercreptorHandler implements org.springframework.web.servlet.H
HandlerMethod handlerMethod = (HandlerMethod) arg2;
Object hander = handlerMethod.getBean();
RequestMapping obj = handlerMethod.getMethod().getAnnotation(RequestMapping.class);
if (StringUtils.isNotBlank(request.getRequestURI()) && !(request.getRequestURI().startsWith("/message/ping") || request.getRequestURI().startsWith("/res/css") || request.getRequestURI().startsWith("/error") || request.getRequestURI().startsWith("/im/"))) {
if (StringUtils.isNotBlank(request.getRequestURI()) &&
!(request.getRequestURI().startsWith("/message/ping") || request.getRequestURI().startsWith("/res/css") || request.getRequestURI().startsWith("/error") || request.getRequestURI().startsWith("/im/"))) {
RequestLog log = new RequestLog();
log.setEndtime(new Date());

View File

@ -16,7 +16,6 @@
*/
package com.chatopera.cc.interceptor;
import com.chatopera.cc.acd.ACDServiceRouter;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.basic.MainUtils;
@ -24,7 +23,6 @@ import com.chatopera.cc.config.MessagingServerConfigure;
import com.chatopera.cc.model.Dict;
import com.chatopera.cc.model.SystemConfig;
import com.chatopera.cc.model.User;
import com.chatopera.cc.proxy.AgentSessionProxy;
import com.chatopera.cc.proxy.UserProxy;
import com.chatopera.cc.util.Menu;
import org.apache.commons.lang.StringUtils;
@ -41,7 +39,6 @@ import javax.servlet.http.HttpServletResponse;
public class UserInterceptorHandler extends HandlerInterceptorAdapter {
private final static Logger logger = LoggerFactory.getLogger(UserInterceptorHandler.class);
private static UserProxy userProxy;
private static AgentSessionProxy agentSessionProxy;
private static Integer webimport;
@Override
@ -124,11 +121,6 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
view.addObject("models", MainContext.getModules());
if (user != null) {
view.addObject(
"agentStatusReport",
ACDServiceRouter.getAcdWorkMonitor().getAgentReport(user.getOrgi()));
}
/**
* WebIM共享用户
*/
@ -150,7 +142,7 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
view.addObject(
"uKeFuSecField", MainContext.getCache().findOneSystemByIdAndOrgi(
Constants.CSKEFU_SYSTEM_SECFIELD,
MainContext.SYSTEM_ORGI)); //处理系统 需要隐藏号码的字段 启动的时候加载
Constants.SYSTEM_ORGI)); //处理系统 需要隐藏号码的字段 启动的时候加载
if (systemConfig != null) {
view.addObject("systemConfig", systemConfig);
@ -183,12 +175,4 @@ public class UserInterceptorHandler extends HandlerInterceptorAdapter {
}
return userProxy;
}
private static AgentSessionProxy getAgentSessionProxy() {
if (agentSessionProxy == null) {
agentSessionProxy = MainContext.getContext().getBean(AgentSessionProxy.class);
}
return agentSessionProxy;
}
}

View File

@ -24,147 +24,193 @@ import java.util.Date;
@Entity
@Table(name = "uk_ad_position")
@org.hibernate.annotations.Proxy(lazy = false)
public class AdType implements java.io.Serializable{
public class AdType implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id ;
private String name ;
private String code ;
private Date createtime ;
private String creater;
private String username ;
private String area ;//分类备注描述信息
private Date updatetime ;
private String parentid ; //父级ID
private String orgi ;
private String imgurl ; //图片URL
private String tiptext ; //title文本
private String url ; //跳转URL
private String content ; //广告文本
private int weight ; //广告权重
private String adpos ; //广告位置
private String status ; //状态
private String adtype ; //广告类型图片/文字
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getImgurl() {
return imgurl;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl;
}
public String getTiptext() {
return tiptext;
}
public void setTiptext(String tiptext) {
this.tiptext = tiptext;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getAdpos() {
return adpos;
}
public void setAdpos(String adpos) {
this.adpos = adpos;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAdtype() {
return adtype;
}
public void setAdtype(String adtype) {
this.adtype = adtype;
}
/**
*
*/
private static final long serialVersionUID = 1115593425069549681L;
private String id;
private String name;
private String code;
private Date createtime;
private String creater;
private String username;
private String area;//分类备注描述信息
private Date updatetime;
private String parentid; //父级ID
private String orgi;
private String imgurl; //图片URL
private String tiptext; //title文本
private String url; //跳转URL
private String content; //广告文本
private int weight; //广告权重
private String adpos; //广告位置
private String status; //状态
private String adtype; //广告类型图片/文字
private String skill;
public String getSkill() {
return skill;
}
public void setSkill(String skill) {
this.skill = skill;
}
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getImgurl() {
return imgurl;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl;
}
public String getTiptext() {
return tiptext;
}
public void setTiptext(String tiptext) {
this.tiptext = tiptext;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getAdpos() {
return adpos;
}
public void setAdpos(String adpos) {
this.adpos = adpos;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAdtype() {
return adtype;
}
public void setAdtype(String adtype) {
this.adtype = adtype;
}
}

View File

@ -72,7 +72,9 @@ public class AgentServiceSummary implements Serializable{
private String updateuser ; //处理人
private Date updatetime ; //处理时间
private String processmemo; //处理备注
private String skill; //技能组
public String getAgentusername() {
return agentusername;
}
@ -328,4 +330,12 @@ public class AgentServiceSummary implements Serializable{
public void setProcessmemo(String processmemo) {
this.processmemo = processmemo;
}
public String getSkill() {
return skill;
}
public void setSkill(String skill) {
this.skill = skill;
}
}

View File

@ -165,8 +165,12 @@ public class AgentStatus implements java.io.Serializable, Comparable<AgentStatus
*/
@Transient
public int getMaxusers() {
SessionConfig sessionConfig = ACDServiceRouter.getAcdPolicyService().initSessionConfig(this.orgi);
return sessionConfig.getMaxuser();
int allMaxuser = this.skills.keySet().stream().mapToInt(k -> {
SessionConfig sessionConfig = ACDServiceRouter.getAcdPolicyService().initSessionConfig(k, this.orgi);
return sessionConfig != null ? sessionConfig.getMaxuser() : 0;
}).sum();
return allMaxuser;
}
public void setMaxusers(int maxusers) {
@ -180,9 +184,11 @@ public class AgentStatus implements java.io.Serializable, Comparable<AgentStatus
*/
@Transient
public int getInitmaxusers() {
SessionConfig sessionConfig = ACDServiceRouter.getAcdPolicyService().initSessionConfig(
this.orgi);
return sessionConfig != null ? sessionConfig.getInitmaxuser() : getMaxusers();
int allInitmaxuser = this.skills.keySet().stream().mapToInt(k -> {
SessionConfig sessionConfig = ACDServiceRouter.getAcdPolicyService().initSessionConfig(k, this.orgi);
return sessionConfig != null ? sessionConfig.getInitmaxuser() : 0;
}).sum();
return allInitmaxuser > 0 ? allInitmaxuser : getMaxusers();
}
public void setInitmaxusers(int initmaxusers) {
@ -224,20 +230,21 @@ public class AgentStatus implements java.io.Serializable, Comparable<AgentStatus
@Override
public int compareTo(AgentStatus o) {
int retValue = 0;
SessionConfig sessionConfig = ACDServiceRouter.getAcdPolicyService().initSessionConfig(
this.orgi);
if (sessionConfig != null && !StringUtils.isBlank(
sessionConfig.getDistribution()) && sessionConfig.getDistribution().equals("0")) {
if (this.getUpdatetime() != null && o.getUpdatetime() != null) {
retValue = (int) (this.getUpdatetime().getTime() - o.getUpdatetime().getTime());
} else if (o.getUpdatetime() != null) {
retValue = -1;
} else {
retValue = 1;
}
} else {
retValue = this.users - o.users;
}
// TODO sessionConfig 组织机构
// SessionConfig sessionConfig = ACDServiceRouter.getAcdPolicyService().initSessionConfig(
// this.orgi);
// if (sessionConfig != null && !StringUtils.isBlank(
// sessionConfig.getDistribution()) && sessionConfig.getDistribution().equals("0")) {
// if (this.getUpdatetime() != null && o.getUpdatetime() != null) {
// retValue = (int) (this.getUpdatetime().getTime() - o.getUpdatetime().getTime());
// } else if (o.getUpdatetime() != null) {
// retValue = -1;
// } else {
// retValue = 1;
// }
// } else {
retValue = this.users - o.users;
// }
return retValue;
}

View File

@ -49,7 +49,27 @@ public class BlackEntity implements java.io.Serializable{
private String agentserviceid ; //agent service id
private String description ; //备注黑名单原因
private int times ; //对话次数
private int chattime ; //最后一次对话时长
private int chattime ; //最后一次对话时长
private String agentusername ; //客服
public String getAgentusername() {
return agentusername;
}
public void setAgentusername(String agentusername) {
this.agentusername = agentusername;
}
public String getSkill() {
return skill;
}
public void setSkill(String skill) {
this.skill = skill;
}
private String skill ; //组织机构ID
@Id
@Column(length = 32)

View File

@ -16,6 +16,7 @@
*/
package com.chatopera.cc.model;
import com.chatopera.cc.basic.Constants;
import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.cache.RedisKey;
import com.chatopera.cc.util.SerializeUtil;
@ -47,7 +48,7 @@ public class Dict<K, V> extends HashMap<K, V> {
logger.debug("[get] key {}", keystr);
Object result = null;
String serialized = MainContext.getRedisCommand().getHashKV(RedisKey.getSysDicHashKeyByOrgi(MainContext.SYSTEM_ORGI), keystr);
String serialized = MainContext.getRedisCommand().getHashKV(RedisKey.getSysDicHashKeyByOrgi(Constants.SYSTEM_ORGI), keystr);
if (StringUtils.isNotBlank(serialized)) {
Object obj = SerializeUtil.deserialize(serialized);
@ -58,9 +59,9 @@ public class Dict<K, V> extends HashMap<K, V> {
}
} else if (keystr.endsWith(".subdic") && keystr.lastIndexOf(".subdic") > 0) {
String id = keystr.substring(0, keystr.lastIndexOf(".subdic"));
SysDic dic = MainContext.getCache().findOneSysDicByIdAndOrgi(id, MainContext.SYSTEM_ORGI);
SysDic dic = MainContext.getCache().findOneSysDicByIdAndOrgi(id, Constants.SYSTEM_ORGI);
if (dic != null) {
SysDic sysDic = MainContext.getCache().findOneSysDicByIdAndOrgi(dic.getDicid(), MainContext.SYSTEM_ORGI);
SysDic sysDic = MainContext.getCache().findOneSysDicByIdAndOrgi(dic.getDicid(), Constants.SYSTEM_ORGI);
result = getDic(sysDic.getCode(), dic.getParentid());
}
}
@ -71,7 +72,7 @@ public class Dict<K, V> extends HashMap<K, V> {
@SuppressWarnings("unchecked")
public List<SysDic> getDic(final String code) {
List<SysDic> result = new ArrayList<SysDic>();
String serialized = MainContext.getRedisCommand().getHashKV(RedisKey.getSysDicHashKeyByOrgi(MainContext.SYSTEM_ORGI), code);
String serialized = MainContext.getRedisCommand().getHashKV(RedisKey.getSysDicHashKeyByOrgi(Constants.SYSTEM_ORGI), code);
if (StringUtils.isNotBlank(serialized)) {
Object obj = SerializeUtil.deserialize(serialized);
@ -104,7 +105,7 @@ public class Dict<K, V> extends HashMap<K, V> {
@SuppressWarnings("unchecked")
public List<SysDic> getDic(final String code, final String id) {
List<SysDic> result = new ArrayList<SysDic>();
String serialized = MainContext.getRedisCommand().getHashKV(RedisKey.getSysDicHashKeyByOrgi(MainContext.SYSTEM_ORGI), code);
String serialized = MainContext.getRedisCommand().getHashKV(RedisKey.getSysDicHashKeyByOrgi(Constants.SYSTEM_ORGI), code);
if (StringUtils.isNotBlank(serialized)) {
Object obj = SerializeUtil.deserialize(serialized);
@ -138,7 +139,7 @@ public class Dict<K, V> extends HashMap<K, V> {
*/
@SuppressWarnings("unchecked")
public List<SysDic> getSysDic(String code) {
return MainContext.getCache().getSysDicItemsByCodeAndOrgi(code, MainContext.SYSTEM_ORGI);
return MainContext.getCache().getSysDicItemsByCodeAndOrgi(code, Constants.SYSTEM_ORGI);
}
/**
@ -148,6 +149,6 @@ public class Dict<K, V> extends HashMap<K, V> {
* @return
*/
public SysDic getDicItem(String code) {
return MainContext.getCache().findOneSysDicByCodeAndOrgi(code, MainContext.SYSTEM_ORGI);
return MainContext.getCache().findOneSysDicByCodeAndOrgi(code, Constants.SYSTEM_ORGI);
}
}

View File

@ -0,0 +1,318 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.model;
import com.chatopera.cc.basic.MainContext;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_callcenter_extention")
@org.hibernate.annotations.Proxy(lazy = false)
public class Extension implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 3932323765657445180L;
private String id;
private String extension;
private String hostid; //Or IP
private String agentno;
private String password; //pbx host password
private String extype; //分机类型 直线分机 : IVR分机组分机 队列分机 会议分机
private String subtype = MainContext.DTMFType.SATISF.toString(); //二级类型如果是 IVR分机则显示IVR类型满意度调查密码身份证号 银行卡号
private boolean callout; //是否允许外呼 OutBound
private boolean playnum; //是否播报工号
private boolean record; //是否录音
private String description; //描述信息·
private String mediapath; //播报工号录音
private String siptrunk;
private String enableai;
private String aiid;
private String sceneid;
private String welcomemsg; //欢迎提示语
private String waitmsg; //等待提示语
private String tipmessage; //识别完成提示语
private String errormessage; //异常完成提示语
private boolean enablewebrtc; //启用WEBRTC
private String bustype;//业务类型电销/问卷
private String proid;//产品ID
private String queid;//问卷ID
private String aitype;//机器人类型smartai/businessai
private String orgi;
private String creater;
private Date createtime = new Date();
private Date updatetime = new Date();
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
/**
* Note: this is a ugly fix for typo
*/
@Column(name = "extention")
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getHostid() {
return hostid;
}
public void setHostid(String hostid) {
this.hostid = hostid;
}
public String getAgentno() {
return agentno;
}
public void setAgentno(String agentno) {
this.agentno = agentno;
}
public boolean isCallout() {
return callout;
}
public void setCallout(boolean callout) {
this.callout = callout;
}
public boolean isPlaynum() {
return playnum;
}
public void setPlaynum(boolean playnum) {
this.playnum = playnum;
}
@Column(name = "srecord")
public boolean isRecord() {
return record;
}
public void setRecord(boolean record) {
this.record = record;
}
public String getExtype() {
return extype;
}
public void setExtype(String extype) {
this.extype = extype;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSubtype() {
return subtype;
}
public void setSubtype(String subtype) {
this.subtype = subtype;
}
public String getMediapath() {
return mediapath;
}
public void setMediapath(String mediapath) {
this.mediapath = mediapath;
}
public String getSiptrunk() {
return siptrunk;
}
public void setSiptrunk(String siptrunk) {
this.siptrunk = siptrunk;
}
public String getEnableai() {
return enableai;
}
public void setEnableai(String enableai) {
this.enableai = enableai;
}
public String getAiid() {
return aiid;
}
public void setAiid(String aiid) {
this.aiid = aiid;
}
public String getSceneid() {
return sceneid;
}
public void setSceneid(String sceneid) {
this.sceneid = sceneid;
}
public String getWelcomemsg() {
return welcomemsg;
}
public void setWelcomemsg(String welcomemsg) {
this.welcomemsg = welcomemsg;
}
public String getWaitmsg() {
return waitmsg;
}
public void setWaitmsg(String waitmsg) {
this.waitmsg = waitmsg;
}
public String getTipmessage() {
return tipmessage;
}
public void setTipmessage(String tipmessage) {
this.tipmessage = tipmessage;
}
public String getErrormessage() {
return errormessage;
}
public void setErrormessage(String errormessage) {
this.errormessage = errormessage;
}
public String getBustype() {
return bustype;
}
public void setBustype(String bustype) {
this.bustype = bustype;
}
public String getProid() {
return proid;
}
public void setProid(String proid) {
this.proid = proid;
}
public String getQueid() {
return queid;
}
public void setQueid(String queid) {
this.queid = queid;
}
public String getAitype() {
return aitype;
}
public void setAitype(String aitype) {
this.aitype = aitype;
}
public boolean isEnablewebrtc() {
return enablewebrtc;
}
public void setEnablewebrtc(boolean enablewebrtc) {
this.enablewebrtc = enablewebrtc;
}
}

View File

@ -1,256 +0,0 @@
/*
* Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.chatopera.cc.model;
import com.chatopera.cc.basic.MainContext;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "uk_callcenter_extention")
@org.hibernate.annotations.Proxy(lazy = false)
public class Extention implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 3932323765657445180L;
private String id;
private String extention;
private String hostid ; //Or IP
private String agentno;
private String password ; //pbx host password
private String extype ; //分机类型 直线分机 : IVR分机组分机 队列分机 会议分机
private String subtype = MainContext.DTMFType.SATISF.toString() ; //二级类型如果是 IVR分机则显示IVR类型满意度调查密码身份证号 银行卡号
private boolean callout; //是否允许外呼 OutBound
private boolean playnum ; //是否播报工号
private boolean record ; //是否录音
private String description ; //描述信息·
private String mediapath ; //播报工号录音
private String siptrunk ;
private String enableai ;
private String aiid ;
private String sceneid ;
private String welcomemsg ; //欢迎提示语
private String waitmsg ; //等待提示语
private String tipmessage ; //识别完成提示语
private String errormessage ; //异常完成提示语
private boolean enablewebrtc ; //启用WEBRTC
private String bustype;//业务类型电销/问卷
private String proid;//产品ID
private String queid;//问卷ID
private String aitype;//机器人类型smartai/businessai
private String orgi;
private String creater ;
private Date createtime = new Date();
private Date updatetime = new Date();
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getExtention() {
return extention;
}
public void setExtention(String extention) {
this.extention = extention;
}
public String getHostid() {
return hostid;
}
public void setHostid(String hostid) {
this.hostid = hostid;
}
public String getAgentno() {
return agentno;
}
public void setAgentno(String agentno) {
this.agentno = agentno;
}
public boolean isCallout() {
return callout;
}
public void setCallout(boolean callout) {
this.callout = callout;
}
public boolean isPlaynum() {
return playnum;
}
public void setPlaynum(boolean playnum) {
this.playnum = playnum;
}
@Column(name="srecord")
public boolean isRecord() {
return record;
}
public void setRecord(boolean record) {
this.record = record;
}
public String getExtype() {
return extype;
}
public void setExtype(String extype) {
this.extype = extype;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSubtype() {
return subtype;
}
public void setSubtype(String subtype) {
this.subtype = subtype;
}
public String getMediapath() {
return mediapath;
}
public void setMediapath(String mediapath) {
this.mediapath = mediapath;
}
public String getSiptrunk() {
return siptrunk;
}
public void setSiptrunk(String siptrunk) {
this.siptrunk = siptrunk;
}
public String getEnableai() {
return enableai;
}
public void setEnableai(String enableai) {
this.enableai = enableai;
}
public String getAiid() {
return aiid;
}
public void setAiid(String aiid) {
this.aiid = aiid;
}
public String getSceneid() {
return sceneid;
}
public void setSceneid(String sceneid) {
this.sceneid = sceneid;
}
public String getWelcomemsg() {
return welcomemsg;
}
public void setWelcomemsg(String welcomemsg) {
this.welcomemsg = welcomemsg;
}
public String getWaitmsg() {
return waitmsg;
}
public void setWaitmsg(String waitmsg) {
this.waitmsg = waitmsg;
}
public String getTipmessage() {
return tipmessage;
}
public void setTipmessage(String tipmessage) {
this.tipmessage = tipmessage;
}
public String getErrormessage() {
return errormessage;
}
public void setErrormessage(String errormessage) {
this.errormessage = errormessage;
}
public String getBustype() {
return bustype;
}
public void setBustype(String bustype) {
this.bustype = bustype;
}
public String getProid() {
return proid;
}
public void setProid(String proid) {
this.proid = proid;
}
public String getQueid() {
return queid;
}
public void setQueid(String queid) {
this.queid = queid;
}
public String getAitype() {
return aitype;
}
public void setAitype(String aitype) {
this.aitype = aitype;
}
public boolean isEnablewebrtc() {
return enablewebrtc;
}
public void setEnablewebrtc(boolean enablewebrtc) {
this.enablewebrtc = enablewebrtc;
}
}

View File

@ -27,122 +27,132 @@ import java.util.Date;
@Table(name = "uk_leavemsg")
@org.hibernate.annotations.Proxy(lazy = false)
public class LeaveMsg {
private String id ;
private String orgi ;
private Date createtime = new Date() ;
private String creater ;
private String name ;
private String mobile ;
private String address ;
private String email ;
private String content ;
private String msgstatus ;
private String qq ;
private String userid ;
private String snsId;
private String id;
private String orgi;
private Date createtime = new Date();
private String creater;
private String name;
private String mobile;
private String address;
private String email;
private String content;
private String msgstatus;
private String qq;
private String userid;
private String skill;
@Transient
private String snsId;
@Transient
private SNSAccount channel;
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public void setId(String id) {
this.id = id;
}
public String getOrgi() {
return orgi;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public Date getCreatetime() {
return createtime;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreater() {
return creater;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getMobile() {
return mobile;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getAddress() {
return address;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail() {
return email;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public void setEmail(String email) {
this.email = email;
}
public String getContent() {
return content;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public void setContent(String content) {
this.content = content;
}
public String getQq() {
return qq;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public String getMsgstatus() {
return msgstatus;
}
public String getSkill() {
return skill;
}
public void setMsgstatus(String msgstatus) {
this.msgstatus = msgstatus;
}
public void setSkill(String skill) {
this.skill = skill;
}
public String getUserid() {
return userid;
}
public String getMsgstatus() {
return msgstatus;
}
public void setUserid(String userid) {
this.userid = userid;
}
public void setMsgstatus(String msgstatus) {
this.msgstatus = msgstatus;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
@Column(name = "snsid")
public String getSnsId() {

View File

@ -26,278 +26,370 @@ import java.util.Date;
@Entity
@Table(name = "uk_callcenter_pbxhost")
@org.hibernate.annotations.Proxy(lazy = false)
public class PbxHost implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 3932323765657445180L;
private String id;
private String name;
private String hostname ; //host name
private String ipaddr ; //IP
private int port ;
private String password ; //pbx host password
private boolean connected ;
private boolean callcenter ;
public class PbxHost implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 3932323765657445180L;
private String id;
private String name;
private String hostname; // host name
private String ipaddr; // IP
private int port; // FreeSWITCH ESL 端口
private int apiport; // Chatopera SWITCH API 端口
private String password; // pbx host password
private boolean connected;
private boolean callcenter;
private String recordpath; // 录音文件存储路径
private String asrrecordpath; // ASR结果文件存储路径
private String ttsrecordpath; // TTS结果文件存储路径
private String ivrpath; // IVR文件路径
private String fspath; // FreeSwitch安装路径
private String device; // 设备厂商
private String recordpath ; //录音文件存储路径
private String asrrecordpath ; //ASR结果文件存储路径
private String ttsrecordpath ; //TTS结果文件存储路径
private String ivrpath ; //IVR文件路径
private String fspath ; //FreeSwitch安装路径
private String device ; //设备厂商
private boolean afterprocess ; //启用坐席后处理功能
private String orgi;
private boolean autoanswer ;
private boolean sipautoanswer ;
private String abscodec = "PCMA"; //默认的 呼叫编码
private String callbacktype ; //回呼送号 号码
private String callbacknumber ;
private String creater ;
private String enableai ;
private String aiid ;
private String sceneid ;
private String welcomemsg ; //欢迎提示语
private String waitmsg ; //等待提示语
private String tipmessage ; //识别完成提示语
private boolean enablewebrtc ; //启用WEBRTC
private String webrtcaddress; //WebRTC访问地址
private String webrtcport; //WebRTC端口
private boolean webrtcssl; //启用SSL
private boolean dissipphone ; //外呼的时候是否隐藏SIP话机上的号码
private Date createtime = new Date();
private Date updatetime = new Date();
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getIpaddr() {
return ipaddr;
}
public void setIpaddr(String ipaddr) {
this.ipaddr = ipaddr;
}
@Transient
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public boolean isAutoanswer() {
return autoanswer;
}
public void setAutoanswer(boolean autoanswer) {
this.autoanswer = autoanswer;
}
public String getCallbacknumber() {
return callbacknumber;
}
public void setCallbacknumber(String callbacknumber) {
this.callbacknumber = callbacknumber;
}
public boolean isCallcenter() {
return callcenter;
}
public void setCallcenter(boolean callcenter) {
this.callcenter = callcenter;
}
public String getRecordpath() {
return recordpath;
}
public void setRecordpath(String recordpath) {
this.recordpath = recordpath;
}
public String getIvrpath() {
return ivrpath;
}
public void setIvrpath(String ivrpath) {
this.ivrpath = ivrpath;
}
public String getFspath() {
return fspath;
}
public void setFspath(String fspath) {
this.fspath = fspath;
}
public String getDevice() {
return device;
}
public void setDevice(String device) {
this.device = device;
}
public String getCallbacktype() {
return callbacktype;
}
public void setCallbacktype(String callbacktype) {
this.callbacktype = callbacktype;
}
public boolean isSipautoanswer() {
return sipautoanswer;
}
public void setSipautoanswer(boolean sipautoanswer) {
this.sipautoanswer = sipautoanswer;
}
public String getAbscodec() {
return abscodec;
}
public void setAbscodec(String abscodec) {
this.abscodec = abscodec;
}
public String getEnableai() {
return enableai;
}
public void setEnableai(String enableai) {
this.enableai = enableai;
}
public String getAiid() {
return aiid;
}
public void setAiid(String aiid) {
this.aiid = aiid;
}
public String getSceneid() {
return sceneid;
}
public void setSceneid(String sceneid) {
this.sceneid = sceneid;
}
public String getWelcomemsg() {
return welcomemsg;
}
public void setWelcomemsg(String welcomemsg) {
this.welcomemsg = welcomemsg;
}
public String getWaitmsg() {
return waitmsg;
}
public void setWaitmsg(String waitmsg) {
this.waitmsg = waitmsg;
}
public String getTipmessage() {
return tipmessage;
}
public void setTipmessage(String tipmessage) {
this.tipmessage = tipmessage;
}
public String getAsrrecordpath() {
return asrrecordpath;
}
public void setAsrrecordpath(String asrrecordpath) {
this.asrrecordpath = asrrecordpath;
}
public String getTtsrecordpath() {
return ttsrecordpath;
}
public void setTtsrecordpath(String ttsrecordpath) {
this.ttsrecordpath = ttsrecordpath;
}
public boolean isAfterprocess() {
return afterprocess;
}
public void setAfterprocess(boolean afterprocess) {
this.afterprocess = afterprocess;
}
public boolean isEnablewebrtc() {
return enablewebrtc;
}
public void setEnablewebrtc(boolean enablewebrtc) {
this.enablewebrtc = enablewebrtc;
}
public String getWebrtcaddress() {
return webrtcaddress;
}
public void setWebrtcaddress(String webrtcaddress) {
this.webrtcaddress = webrtcaddress;
}
public String getWebrtcport() {
return webrtcport;
}
public void setWebrtcport(String webrtcport) {
this.webrtcport = webrtcport;
}
public boolean isWebrtcssl() {
return webrtcssl;
}
public void setWebrtcssl(boolean webrtcssl) {
this.webrtcssl = webrtcssl;
}
public boolean isDissipphone() {
return dissipphone;
}
public void setDissipphone(boolean dissipphone) {
this.dissipphone = dissipphone;
}
private boolean afterprocess; //启用坐席后处理功能
private String orgi;
private String organ;
private boolean autoanswer;
private boolean sipautoanswer;
private String abscodec = "PCMA"; //默认的 呼叫编码
private String callbacktype; //回呼送号 号码
private String callbacknumber;
private String creater;
private String enableai;
private String aiid;
private String sceneid;
private String welcomemsg; // 欢迎提示语
private String waitmsg; // 等待提示语
private String tipmessage; // 识别完成提示语
private boolean enablewebrtc; // 启用WEBRTC
private String webrtcaddress; // WebRTC访问地址
private int webrtcport; // WebRTC端口
private boolean webrtcssl; // 启用SSL
private boolean dissipphone; //外呼的时候是否隐藏SIP话机上的号码
private String syncstatus; // 同步执行状态: SYNCED 已经同步SYNCING 同步中
// 如果为null或NOTSYNC 代表未同步
// SYNCFAIL同步失败
private Date createtime = new Date();
private Date updatetime = new Date();
@Id
@Column(length = 32)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOrgi() {
return orgi;
}
public void setOrgi(String orgi) {
this.orgi = orgi;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getIpaddr() {
return ipaddr;
}
public void setIpaddr(String ipaddr) {
this.ipaddr = ipaddr;
}
@Transient
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public boolean isAutoanswer() {
return autoanswer;
}
public void setAutoanswer(boolean autoanswer) {
this.autoanswer = autoanswer;
}
public String getCallbacknumber() {
return callbacknumber;
}
public void setCallbacknumber(String callbacknumber) {
this.callbacknumber = callbacknumber;
}
public boolean isCallcenter() {
return callcenter;
}
public void setCallcenter(boolean callcenter) {
this.callcenter = callcenter;
}
public String getRecordpath() {
return recordpath;
}
public void setRecordpath(String recordpath) {
this.recordpath = recordpath;
}
public String getIvrpath() {
return ivrpath;
}
public void setIvrpath(String ivrpath) {
this.ivrpath = ivrpath;
}
public String getFspath() {
return fspath;
}
public void setFspath(String fspath) {
this.fspath = fspath;
}
public String getDevice() {
return device;
}
public void setDevice(String device) {
this.device = device;
}
public String getCallbacktype() {
return callbacktype;
}
public void setCallbacktype(String callbacktype) {
this.callbacktype = callbacktype;
}
public boolean isSipautoanswer() {
return sipautoanswer;
}
public void setSipautoanswer(boolean sipautoanswer) {
this.sipautoanswer = sipautoanswer;
}
public String getAbscodec() {
return abscodec;
}
public void setAbscodec(String abscodec) {
this.abscodec = abscodec;
}
public String getEnableai() {
return enableai;
}
public void setEnableai(String enableai) {
this.enableai = enableai;
}
public String getAiid() {
return aiid;
}
public void setAiid(String aiid) {
this.aiid = aiid;
}
public String getSceneid() {
return sceneid;
}
public void setSceneid(String sceneid) {
this.sceneid = sceneid;
}
public String getWelcomemsg() {
return welcomemsg;
}
public void setWelcomemsg(String welcomemsg) {
this.welcomemsg = welcomemsg;
}
public String getWaitmsg() {
return waitmsg;
}
public void setWaitmsg(String waitmsg) {
this.waitmsg = waitmsg;
}
public String getTipmessage() {
return tipmessage;
}
public void setTipmessage(String tipmessage) {
this.tipmessage = tipmessage;
}
public String getAsrrecordpath() {
return asrrecordpath;
}
public void setAsrrecordpath(String asrrecordpath) {
this.asrrecordpath = asrrecordpath;
}
public String getTtsrecordpath() {
return ttsrecordpath;
}
public void setTtsrecordpath(String ttsrecordpath) {
this.ttsrecordpath = ttsrecordpath;
}
public boolean isAfterprocess() {
return afterprocess;
}
public void setAfterprocess(boolean afterprocess) {
this.afterprocess = afterprocess;
}
public boolean isEnablewebrtc() {
return enablewebrtc;
}
public void setEnablewebrtc(boolean enablewebrtc) {
this.enablewebrtc = enablewebrtc;
}
public String getWebrtcaddress() {
return webrtcaddress;
}
public void setWebrtcaddress(String webrtcaddress) {
this.webrtcaddress = webrtcaddress;
}
public int getWebrtcport() {
return webrtcport;
}
public void setWebrtcport(int webrtcport) {
this.webrtcport = webrtcport;
}
public boolean isWebrtcssl() {
return webrtcssl;
}
public void setWebrtcssl(boolean webrtcssl) {
this.webrtcssl = webrtcssl;
}
public boolean isDissipphone() {
return dissipphone;
}
public void setDissipphone(boolean dissipphone) {
this.dissipphone = dissipphone;
}
public String getOrgan() {
return organ;
}
public void setOrgan(String organ) {
this.organ = organ;
}
public int getApiport() {
return apiport;
}
public void setApiport(int apiport) {
this.apiport = apiport;
}
public String getSyncstatus() {
return syncstatus;
}
public void setSyncstatus(String syncstatus) {
this.syncstatus = syncstatus;
}
}

Some files were not shown because too many files have changed in this diff Show More