Просмотр исходного кода

Merge remote-tracking branch 'remotes/origin/locky' into test

Ansjer 2 лет назад
Родитель
Сommit
a3535991fa

+ 4 - 0
Controller/AiController.py

@@ -18,6 +18,7 @@ from Object.enums.MessageTypeEnum import MessageTypeEnum
 from Object.utils import LocalDateTimeUtil
 from Service.CommonService import CommonService
 from Service.EquipmentInfoService import EquipmentInfoService
+from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
 
 LOGGING = logging.getLogger('info')
@@ -183,6 +184,9 @@ class AiView(View):
                         kwargs.pop('uid')
                         kwargs.pop('channel')
                         PushObject.android_jpush(**kwargs)
+                    elif push_type == 3:
+                        huawei_push_object = HuaweiPushObject()
+                        huawei_push_object.send_push_notify_message(**kwargs)
                     elif push_type == 4:  # android 小米推送
                         PushObject.android_xmpush(**kwargs)
                     elif push_type == 5:  # android vivo推送

+ 4 - 0
Controller/ComboCron/ComboCronPushController.py

@@ -16,6 +16,7 @@ from django.views import View
 from Model.models import UnicomComboOrderInfo, UnicomDeviceInfo, GatewayPush, SysMsgModel, UnicomFlowPush, Device_User
 from Object.AliyunSmsObject import AliyunSmsObject
 from Object.ResponseObject import ResponseObject
+from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
 
 
@@ -229,6 +230,9 @@ class ComboCronPushView(View):
             # android 极光推送
             elif push_type == 2:
                 PushObject.android_jpush(**kwargs)
+            elif push_type == 3:
+                huawei_push_object = HuaweiPushObject()
+                huawei_push_object.send_push_notify_message(**kwargs)
             # android 小米推送
             elif push_type == 4:
                 PushObject.android_xmpush(**kwargs)

+ 4 - 0
Controller/PowerWarningController.py

@@ -12,6 +12,7 @@ from django.views.generic.base import View
 
 from Model.models import UidPushModel, SysMsgModel, Device_Info
 from Object.RedisObject import RedisObject
+from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
 
 
@@ -91,6 +92,9 @@ class PowerWarningView(View):
                         PushObject.android_fcm_push(**kwargs)
                     elif push_type == 2:  # android jpush
                         PushObject.android_jpush(**kwargs)
+                    elif push_type == 3:
+                        huawei_push_object = HuaweiPushObject()
+                        huawei_push_object.send_push_notify_message(**kwargs)
                     elif push_type == 4:  # android 小米推送
                         PushObject.android_xmpush(**kwargs)
                     elif push_type == 5:  # android vivo推送

+ 7 - 0
Controller/gatewayController.py

@@ -15,6 +15,7 @@ from Object.ResponseObject import ResponseObject
 from Object.utils import LocalDateTimeUtil
 from Service.CommonService import CommonService
 from Service.EquipmentInfoService import EquipmentInfoService
+from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
 
 
@@ -173,6 +174,9 @@ class GatewayView(View):
                             PushObject.android_fcm_push(**kwargs)
                         elif push_type == 2:  # android 极光推送
                             PushObject.android_jpush(**kwargs)
+                        elif push_type == 3:
+                            huawei_push_object = HuaweiPushObject()
+                            huawei_push_object.send_push_notify_message(**kwargs)
                         elif push_type == 4:  # android 小米推送
                             PushObject.android_xmpush(**kwargs)
                         elif push_type == 5:  # android vivo推送
@@ -271,6 +275,9 @@ class GatewayView(View):
                                 PushObject.android_fcm_push(**kwargs)
                             elif push_type == 2:  # android 极光推送
                                 PushObject.android_jpush(**kwargs)
+                            elif push_type == 3:
+                                huawei_push_object = HuaweiPushObject()
+                                huawei_push_object.send_push_notify_message(**kwargs)
                             elif push_type == 4:  # android 小米推送
                                 PushObject.android_xmpush(**kwargs)
                             elif push_type == 5:  # android vivo推送

+ 13 - 10
Service/DevicePushService.py

@@ -165,7 +165,7 @@ class DevicePushService:
         发送app消息推送
         """
         try:
-            kwag_args = param['kwag_args']
+            kwargs = param['kwag_args']
             result = {'do_apns_code': '', 'do_fcm_code': '', 'do_jpush_code': '', 'do_xmpush_code': '',
                       'do_vivopush_code': '', 'do_meizupush_code': '', 'do_oppopush_code': ''}
             # 判断是否进行APP消息推送,如app_push不为空,则不进行推送
@@ -185,19 +185,22 @@ class DevicePushService:
                     push_thread.start()
                 else:
                     if push_type == 0:  # ios apns
-                        result['do_apns_code'] = cls.do_apns(**kwag_args)
+                        result['do_apns_code'] = cls.do_apns(**kwargs)
                     elif push_type == 1:  # android gcm
-                        result['do_fcm_code'] = cls.do_fcm(**kwag_args)
+                        result['do_fcm_code'] = cls.do_fcm(**kwargs)
                     elif push_type == 2:  # android jpush
-                        result['do_jpush_code'] = cls.do_jpush(**kwag_args)
+                        result['do_jpush_code'] = cls.do_jpush(**kwargs)
+                    elif push_type == 3:
+                        huawei_push_object = HuaweiPushObject()
+                        huawei_push_object.send_push_notify_message(**kwargs)
                     elif push_type == 4:  # android xmpush
-                        result['do_xmpush_code'] = cls.do_xmpush(**kwag_args)
+                        result['do_xmpush_code'] = cls.do_xmpush(**kwargs)
                     elif push_type == 5:  # android vivopush
-                        result['do_vivopush_code'] = PushObject.android_vivopush(**kwag_args)
+                        result['do_vivopush_code'] = PushObject.android_vivopush(**kwargs)
                     elif push_type == 6:  # android oppopush
-                        result['do_oppopush_code'] = cls.do_oppopush(**kwag_args)
+                        result['do_oppopush_code'] = cls.do_oppopush(**kwargs)
                     elif push_type == 7:  # android meizupush
-                        result['do_meizupush_code'] = PushObject.android_meizupush(**kwag_args)
+                        result['do_meizupush_code'] = PushObject.android_meizupush(**kwargs)
             return result
         except Exception as e:
             LOGGING.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
@@ -464,8 +467,8 @@ class DevicePushService:
                                             msg_text, uid, channel, image_url)
             elif push_type == 3:
                 huawei_push_object = HuaweiPushObject()
-                huawei_push_object.send_push_notify_message(msg_title=msg_title, msg_text=msg_text,
-                                                            image_url=image_url, token_val=token_val)
+                huawei_push_object.send_push_notify_message(token_val=token_val, msg_title=msg_title, msg_text=msg_text,
+                                                            image_url=image_url)
             elif push_type == 4:
                 PushObject.android_xmpush(uid, appBundleId, token_val, n_time, event_type, msg_title,
                                           msg_text, uid, channel, image_url)

+ 7 - 5
Service/HuaweiPushService/HuaweiPushService.py

@@ -17,15 +17,17 @@ class HuaweiPushObject:
         """init sdk app"""
         push_admin.initialize_app(self.app_id, self.app_secret)
 
-    def send_push_notify_message(self, msg_title, msg_text, image_url, token_val):
+    def send_push_notify_message(self, token_val, msg_title, msg_text, image_url=None):
         """
         发送推送消息
-
-        :param: token
-        :return:
+        @param token_val: 手机推送token
+        @param msg_title: 标题
+        @param msg_text: 内容
+        @param image_url: 图片链接
+        @return:
         """
         logger = logging.getLogger('info')
-        logger.info('华为推送参数:{}, {}, {}, {}'.format(msg_title, msg_text, image_url, token_val))
+        logger.info('华为推送参数:{}, {}, {}, {}'.format(token_val, msg_title, msg_text, image_url))
 
         msg_title = '设备昵称: {}'.format(msg_title)
         notification = messaging.Notification(