Browse Source

外呼系统开发

anderx 1 year ago
parent
commit
9cdf495898

+ 30 - 10
src/main/java/com/goafanti/customer/service/impl/UserOutboundServiceImpl.java

@@ -92,6 +92,7 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         Map<String,Object> request=new HashMap<>();
         request.put("agent",in.getAgent());
         request.put("callee",in.getCallee());
+        request.put("userData",in.getUid());
         param.put("request",request);
         HttpUtils httpUtils=new HttpUtils();
         String s = httpUtils.sendHttpsRequest(url, "POST", param);
@@ -104,12 +105,12 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         msg = result.getString("msg");
         if (StringUtils.isNotBlank(msg)){
             if (msg.equals("成功")){
-//                if (StringUtils.isNotBlank(in.getUid())){
-//                    User u =new User();
-//                    u.setId(in.getUid());
-//                    u.setCallStatus(1);
-//                    userMapper.update(u);
-//                }
+                if (StringUtils.isNotBlank(in.getUid())){
+                    User u =new User();
+                    u.setId(in.getUid());
+                    u.setCallStatus(1);
+                    userMapper.update(u);
+                }
                 return new Result().data("呼叫成功");
             }
             return new Result().error(new Error(msg));
@@ -125,6 +126,7 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         Map<String,Object> request=new HashMap<>();
         request.put("agent",in.getAgent());
         request.put("transAgent",in.getTransAgent());
+        request.put("userData",in.getUid());
         param.put("request",request);
         HttpUtils httpUtils=new HttpUtils();
         String s = httpUtils.sendHttpsRequest(url, "POST", param);
@@ -155,14 +157,28 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         String typeResult=String.valueOf(notify.get("typeResult"));
         String timeLength=String.valueOf(notify.get("timeLength"));
         String callResultMsg=String.valueOf(notify.get("callResultMsg"));
+        String userDate=String.valueOf(notify.get("userData"));
         String name=admin.getName();
         String ContactName=null;
         String uid=null;
+        if (userDate!=null){
+            uid=userDate;
+
+        }
         List<OrganizationContactBook> books = organizationContactBookMapper.selectUserByContact(callee);
         if (books!=null){
-            OrganizationContactBook book1 = books.get(0);
-            ContactName=book1.getName();
-            uid=book1.getUid();
+            if (uid==null){
+                OrganizationContactBook book1 = books.get(0);
+                ContactName=book1.getName();
+                uid=book1.getUid();
+            }else {
+                for (OrganizationContactBook item:books){
+                    if (item.getUid().equals(uid)){
+                        ContactName=item.getName();
+                        break;
+                    }
+                }
+            }
         }
         CallLog callLog=new CallLog();
         callLog.setUid(uid);
@@ -179,6 +195,7 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         pushCountUser(uid);
         //需要关闭客户呼叫中
         try {
+            LoggerUtils.debug(getClass(),String.format("websocket通信成功=》{}",callResultMsg));
             systemWebSocketHandler.sendMessageToUser(admin.getId(), new TextMessage(callResultMsg));
         }catch (Exception e ){
             LoggerUtils.error(getClass(),"websocket通信失败");
@@ -203,7 +220,10 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         mid.setCallCount(count);
         mid.setCallDuration(duration);
         userMidMapper.updateByUid(mid);
-
+        User u =new User();
+        u.setId(uid);
+        u.setCallStatus(0);
+        userMapper.update(u);
     }
 
     @Override