diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/api/ApiWlContactsController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/api/ApiWlContactsController.java index 3361b18d..3ed70c9d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/api/ApiWlContactsController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/api/ApiWlContactsController.java @@ -136,7 +136,7 @@ public class ApiWlContactsController extends Handler { final String uid = j.get("uid").getAsString(); final String sid = j.get("sid").getAsString(); final String cid = j.get("cid").getAsString(); - Contacts record = contactsRes.findOneByWluidAndWlsidAndWlcid(uid, sid, cid); + Contacts record = contactsRes.findOneByWluidAndWlsidAndWlcidAndDatastatus(uid, sid, cid, false); boolean isNew = false; if (record == null) { // create new obj diff --git a/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/IMController.java index 13cafd1e..cd51d2b6 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/controller/apps/IMController.java @@ -307,7 +307,7 @@ public class IMController extends Handler { final String company_name, final String system_name) { if (StringUtils.isNotBlank(uid) && StringUtils.isNotBlank(sid) && StringUtils.isNotBlank(cid)) { - Contacts data = contactsRes.findOneByWluidAndWlsidAndWlcid(uid, sid, cid); + Contacts data = contactsRes.findOneByWluidAndWlsidAndWlcidAndDatastatus(uid, sid, cid, false); if (data == null) { data = new Contacts(); data.setCreater(gid); @@ -367,7 +367,7 @@ public class IMController extends Handler { onlineUserRes.save(onlineUser); } - Contacts usc = contactsRes.findOneByWluidAndWlsidAndWlcid(uid, sid, cid); + Contacts usc = contactsRes.findOneByWluidAndWlsidAndWlcidAndDatastatus(uid, sid, cid, false); if (usc != null) { return "usc"; } else { @@ -766,7 +766,7 @@ public class IMController extends Handler { String cid = (String) request.getSession().getAttribute("Sessioncid"); if (StringUtils.isNotBlank(uid) && StringUtils.isNotBlank(sid) && StringUtils.isNotBlank(cid)) { - Contacts contacts1 = contactsRes.findOneByWluidAndWlsidAndWlcid(uid, sid, cid); + Contacts contacts1 = contactsRes.findOneByWluidAndWlsidAndWlcidAndDatastatus(uid, sid, cid, false); if (contacts1 != null) { agentUserRepository.findOneByUseridAndOrgi(userid, orgi).ifPresent(p -> { // 关联AgentService的联系人 diff --git a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepository.java b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepository.java index 2adb4cd2..28b008aa 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepository.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/persistence/es/ContactsRepository.java @@ -29,7 +29,7 @@ public interface ContactsRepository extends ElasticsearchRepository findOneByDatastatusIsFalseAndPhoneAndOrgi(String phone, String orgi); - Contacts findOneByWluidAndWlsidAndWlcid(String wluid, String wlsid, String wlcid); + Contacts findOneByWluidAndWlsidAndWlcidAndDatastatus(String wluid, String wlsid, String wlcid, Boolean datastatus); List findByskypeidAndDatastatus(String skypeid, Boolean datastatus); diff --git a/contact-center/assets/mysql.setup.db.sh b/contact-center/assets/mysql.setup.db.sh index c6978c90..04902069 100755 --- a/contact-center/assets/mysql.setup.db.sh +++ b/contact-center/assets/mysql.setup.db.sh @@ -12,8 +12,6 @@ CONTACT_CENTER_DB=`parse_dbname ${SPRING_DATASOURCE_URL}` CONTACT_CENTER_WAR=/opt/chatopera/contact-center.war MYSQL_SCRIPT_NAME=cosinee-MySQL-slim.sql -println "[setup] connecting to $MYSQL_WRITEMODE_IP:$MYSQL_WRITEMODE_PORT/$CONTACT_CENTER_DB with $SPRING_DATASOURCE_USERNAME/****" - # functions function import_db(){ if [ ! -f $1 ]; then exit 1; fi @@ -57,6 +55,14 @@ function init_db(){ # main [ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +println "[setup] connecting to $MYSQL_WRITEMODE_IP:$MYSQL_WRITEMODE_PORT/$CONTACT_CENTER_DB with $SPRING_DATASOURCE_USERNAME/****" + +## wait for database connection ... +while ! mysqladmin --user=${SPRING_DATASOURCE_USERNAME} --password=${SPRING_DATASOURCE_PASSWORD} --host=${MYSQL_WRITEMODE_IP} --port=${MYSQL_WRITEMODE_PORT} ping --silent &> /dev/null ; do + echo "Waiting for database connection..." + sleep 2 +done + # check if database exist, if not, create it. mysqlshow -h ${MYSQL_WRITEMODE_IP} \ -P ${MYSQL_WRITEMODE_PORT} \ diff --git a/contact-center/assets/mysql.upgrade.db.sh b/contact-center/assets/mysql.upgrade.db.sh index ec4a78dd..4d6ef332 100755 --- a/contact-center/assets/mysql.upgrade.db.sh +++ b/contact-center/assets/mysql.upgrade.db.sh @@ -13,8 +13,6 @@ CONTACT_CENTER_WAR=/opt/chatopera/contact-center.war APP_WAR_EXTRACTED=/tmp/ROOT UPGRADE_DB_SCRIPT_DIR=$APP_WAR_EXTRACTED/upgrade -println "[upgrade] connecting to $MYSQL_WRITEMODE_IP:$MYSQL_WRITEMODE_PORT/$CONTACT_CENTER_DB with $SPRING_DATASOURCE_USERNAME/****" - # functions function upgrade_db(){ if [ ! -f $1 ]; then exit 1; fi @@ -46,12 +44,19 @@ function extract_war(){ # main [ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return +println "[upgrade] connecting to $MYSQL_WRITEMODE_IP:$MYSQL_WRITEMODE_PORT/$CONTACT_CENTER_DB with $SPRING_DATASOURCE_USERNAME/****" ## check upgrade footprint if [ -f /opt/chatopera/upgrade.his ]; then echo "[upgrade] upgrade has been done with previous start." exit 0 fi +## wait for database connection ... +while ! mysqladmin --user=${SPRING_DATASOURCE_USERNAME} --password=${SPRING_DATASOURCE_PASSWORD} --host=${MYSQL_WRITEMODE_IP} --port=${MYSQL_WRITEMODE_PORT} ping --silent &> /dev/null ; do + echo "Waiting for database connection..." + sleep 2 +done + ## check root dir if [ ! -d $APP_WAR_EXTRACTED ]; then extract_war @@ -73,4 +78,4 @@ fi ## touch upgrade footprint if [ ! -f /opt/chatopera/upgrade.his ]; then touch /opt/chatopera/upgrade.his -fi \ No newline at end of file +fi