Browse Source

修改普通电话记录通过tcp标记

weizhengliang 2 years ago
parent
commit
1d3d5c68d4

+ 12 - 10
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchCallRecordsActivity.kt

@@ -145,17 +145,19 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
                                 val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:" + receivedData!!.phoneNumber))
                                 startActivity(intent)
 
-                                //发送tcp
-                                /*val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, receivedData!!.deviceId)
-                                NettyClient.instance.sendMsg(tcpModel.toJson())
-                                    .subscribe { res: Boolean ->
-                                        if (res) {
-                                            Log.d(TAG, "TCP.发送消息完成")
-                                        } else {
-                                            Log.e(TAG, "TCP.发送消息失败")
-                                            HandleTcpConnect.instance.tcpReConnectWithMsgShow()
+                                if (!Constants.uploadCalllog) {
+                                    //发送tcp
+                                    val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, receivedData!!.deviceId)
+                                    NettyClient.instance.sendMsg(tcpModel.toJson())
+                                        .subscribe { res: Boolean ->
+                                            if (res) {
+                                                Log.d(TAG, "TCP.发送消息完成")
+                                            } else {
+                                                Log.e(TAG, "TCP.发送消息失败")
+                                                HandleTcpConnect.instance.tcpReConnectWithMsgShow()
+                                            }
                                         }
-                                    }*/
+                                }
                             } else {
                                 showMessage(R.string.call_phone_failed)
                             }

+ 13 - 10
home/src/main/code/com/wdkl/ncs/android/component/home/adapter/TakeoverItemAdapter.kt

@@ -107,16 +107,19 @@ class TakeoverItemAdapter(var data:ArrayList<JsonObject>, val context: Context)
                             context.startActivity(intent)
                             //Constants.phoneState = Constants.PHONE_OUTGOING
 
-                            //发送tcp
-                            /*val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, itemData.get("id").asInt)
-                            NettyClient.instance.sendMsg(tcpModel.toJson()).subscribe { res: Boolean ->
-                                if (res) {
-                                    Log.d(TAG, "TCP.发送消息完成")
-                                } else {
-                                    Log.e(TAG, "TCP.发送消息失败")
-                                    HandleTcpConnect.instance.tcpReConnectWithMsgShow()
-                                }
-                            }*/
+                            if (!Constants.uploadCalllog) {
+                                //发送tcp
+                                val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, itemData.get("id").asInt)
+                                NettyClient.instance.sendMsg(tcpModel.toJson())
+                                    .subscribe { res: Boolean ->
+                                        if (res) {
+                                            Log.d(TAG, "TCP.发送消息完成")
+                                        } else {
+                                            Log.e(TAG, "TCP.发送消息失败")
+                                            HandleTcpConnect.instance.tcpReConnectWithMsgShow()
+                                        }
+                                    }
+                            }
                         } catch (e: Exception) {
                             showMessage(R.string.call_phone_failed)
                         }

+ 13 - 10
home/src/main/code/com/wdkl/ncs/android/component/home/adapter/TakeoverItemSearchAdapter.kt

@@ -96,16 +96,19 @@ class TakeoverItemSearchAdapter : FuzzySearchBaseAdapter<ContactItemEntity, Take
                         context.startActivity(intent)
                         //Constants.phoneState = Constants.PHONE_OUTGOING
 
-                        //发送tcp
-                        /*val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, itemData.id)
-                        NettyClient.instance.sendMsg(tcpModel.toJson()).subscribe { res: Boolean ->
-                            if (res) {
-                                Log.d(TAG, "TCP.发送消息完成")
-                            } else {
-                                Log.e(TAG, "TCP.发送消息失败")
-                                HandleTcpConnect.instance.tcpReConnectWithMsgShow()
-                            }
-                        }*/
+                        if (!Constants.uploadCalllog) {
+                            //发送tcp
+                            val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, itemData.id)
+                            NettyClient.instance.sendMsg(tcpModel.toJson())
+                                .subscribe { res: Boolean ->
+                                    if (res) {
+                                        Log.d(TAG, "TCP.发送消息完成")
+                                    } else {
+                                        Log.e(TAG, "TCP.发送消息失败")
+                                        HandleTcpConnect.instance.tcpReConnectWithMsgShow()
+                                    }
+                                }
+                        }
                     } catch (e: Exception) {
                         showMessage(R.string.call_phone_failed)
                     }

+ 12 - 10
home/src/main/code/com/wdkl/ncs/android/component/home/adapter/WatchContactsItemAdapter.kt

@@ -82,17 +82,19 @@ class WatchContactsItemAdapter(val data:ArrayList<WatchContactsVO>, val context:
                             val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:" + itemData.phoneNumber))
                             context.startActivity(intent)
 
-                            //发送tcp
-                            /*val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, itemData.deviceId)
-                            NettyClient.instance.sendMsg(tcpModel.toJson())
-                                .subscribe { res: Boolean ->
-                                    if (res) {
-                                        Log.d(TAG, "TCP.发送消息完成")
-                                    } else {
-                                        Log.e(TAG, "TCP.发送消息失败")
-                                        HandleTcpConnect.instance.tcpReConnectWithMsgShow()
+                            if (!Constants.uploadCalllog) {
+                                //发送tcp
+                                val tcpModel = PhoneUtil.phoneCall(Constants.deviceId, itemData.deviceId)
+                                NettyClient.instance.sendMsg(tcpModel.toJson())
+                                    .subscribe { res: Boolean ->
+                                        if (res) {
+                                            Log.d(TAG, "TCP.发送消息完成")
+                                        } else {
+                                            Log.e(TAG, "TCP.发送消息失败")
+                                            HandleTcpConnect.instance.tcpReConnectWithMsgShow()
+                                        }
                                     }
-                                }*/
+                            }
                         } else {
                             showMessage(R.string.call_phone_failed)
                         }

+ 32 - 27
home/src/main/code/com/wdkl/ncs/android/component/home/service/PhoneStateReceiver.java

@@ -85,21 +85,24 @@ public class PhoneStateReceiver extends BroadcastReceiver {
                 //待机中
                 //Log.d(TAG, "PhoneStateReceiver idle");
                 if (Constants.Companion.getPhoneState() != Constants.PHONE_IDLE) {
-                    //发送tcp
-                    /*if (Constants.Companion.getPhoneDataVO() != null) {
-                        TcpModel tcpModel = PhoneUtil.phoneHandoff(Constants.Companion.getDeviceId(), Constants.Companion.getPhoneDataVO());
-                        NettyClient.Companion.getInstance().sendMsg(tcpModel.toJson()).subscribe(it -> {
-                            if (it) {
-                                Log.d(TAG, "TCP.发送消息完成");
-                            } else {
-                                Log.e(TAG, "TCP.发送消息失败");
-                                HandleTcpConnect.Companion.getInstance().tcpReConnectWithMsgShow();
-                            }
-                        });
-                    }*/
-
-                    //通话结束,上传通话记录
-                    EventBus.getDefault().post(new MessageEvent("call_end", Constants.EVENT_CALL_END));
+                    if (!Constants.uploadCalllog) {
+                        //发送tcp
+                        if (Constants.Companion.getPhoneDataVO() != null) {
+                            TcpModel tcpModel = PhoneUtil.phoneHandoff(Constants.Companion.getDeviceId(), Constants.Companion.getPhoneDataVO());
+                            NettyClient.Companion.getInstance().sendMsg(tcpModel.toJson()).subscribe(it -> {
+                                if (it) {
+                                    Log.d(TAG, "TCP.发送消息完成");
+                                } else {
+                                    Log.e(TAG, "TCP.发送消息失败");
+                                    HandleTcpConnect.Companion.getInstance().tcpReConnectWithMsgShow();
+                                }
+                            });
+                            Constants.Companion.setPhoneDataVO(null);
+                        }
+                    } else {
+                        //通话结束,上传通话记录
+                        EventBus.getDefault().post(new MessageEvent("call_end", Constants.EVENT_CALL_END));
+                    }
                 }
 
                 DeviceChannel.calling = false;
@@ -152,18 +155,20 @@ public class PhoneStateReceiver extends BroadcastReceiver {
                 RecordHelper.getInstance().stopCancelRecordByOther(true);
                 EventBus.getDefault().post(new MessageEvent(true, Constants.EVENT_CLEAR_IM));
                 if (Constants.Companion.getPhoneState() == Constants.PHONE_INCOMING) {
-                    //发送tcp
-                    /*if (Constants.Companion.getPhoneDataVO() != null) {
-                        TcpModel tcpModel = PhoneUtil.phoneAccept(Constants.Companion.getDeviceId(), Constants.Companion.getPhoneDataVO());
-                        NettyClient.Companion.getInstance().sendMsg(tcpModel.toJson()).subscribe(it -> {
-                            if (it) {
-                                Log.d(TAG, "TCP.发送消息完成");
-                            } else {
-                                Log.e(TAG, "TCP.发送消息失败");
-                                HandleTcpConnect.Companion.getInstance().tcpReConnectWithMsgShow();
-                            }
-                        });
-                    }*/
+                    if (!Constants.uploadCalllog) {
+                        //发送tcp
+                        if (Constants.Companion.getPhoneDataVO() != null) {
+                            TcpModel tcpModel = PhoneUtil.phoneAccept(Constants.Companion.getDeviceId(), Constants.Companion.getPhoneDataVO());
+                            NettyClient.Companion.getInstance().sendMsg(tcpModel.toJson()).subscribe(it -> {
+                                if (it) {
+                                    Log.d(TAG, "TCP.发送消息完成");
+                                } else {
+                                    Log.e(TAG, "TCP.发送消息失败");
+                                    HandleTcpConnect.Companion.getInstance().tcpReConnectWithMsgShow();
+                                }
+                            });
+                        }
+                    }
                 } else if (Constants.Companion.getPhoneState() == Constants.PHONE_IDLE) {
                     Constants.Companion.setPhoneState(Constants.PHONE_OUTGOING);
                 } else {

+ 1 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt

@@ -52,6 +52,7 @@ class Constants {
         var nursePhoneType = CommunicationEnum.MOBILE_PHONE.value()
 
         var phoneDataVO: InteractionVO? = null
+        const val uploadCalllog = false
 
         var eventList = ArrayList<InteractionVO>()
         var oldEvent = false