浏览代码

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer into peng

peng 10 月之前
父节点
当前提交
7b82758a34

+ 20 - 15
CeleryTask/TimeAlbumTask.py

@@ -38,7 +38,7 @@ def generate_video(image_files, output_path):
     start_xvfb()
     try:
         video_files = []
-        music_path = "/web/test/ASJServer/static/temp/music.mp3"
+        music_path = "static/ffmpeg/music.mp3"
         # 定义特效列表
         transitions = [
             "BowTieHorizontal.glsl",
@@ -58,36 +58,41 @@ def generate_video(image_files, output_path):
             video_files.append(output_video)
 
             cmd = [
-                'ffmpeg', '-loop', '1', '-i', image_files[i],
+                'static/ffmpeg/ffmpeg4', '-loop', '1', '-i', image_files[i],
                 '-loop', '1', '-i', image_files[i + 1],
                 '-filter_complex',
-                f'gltransition=duration=1:offset=0.7:source=/web/test/ASJServer/static/gl-transitions/{transitions[i]}',
+                f'gltransition=duration=1:offset=0.7:source=static/gl-transitions/{transitions[i]}',
                 '-t', '2', output_video
             ]
 
             subprocess.run(cmd, check=True)
 
         # 生成拼接列表文件
-        with open(os.path.join(output_path, 'filelist.txt'), 'w') as f:
+        filelist_path = os.path.join(output_path, 'filelist.txt')
+        with open(filelist_path, 'w') as f:
             for video in video_files:
-                f.write(f"file '{video}'\n")
+                f.write(f"file '{os.path.relpath(video, output_path)}'\n")  # 使用相对路径
 
-        # 拼接视频
-        final_output = os.path.join(output_path, 'final_output.mp4')
+        # 拼接并生成背景音乐
+        final_output_with_music = os.path.join(output_path, 'final_output_with_music.mp4')
         subprocess.run(
-            ['ffmpeg', '-f', 'concat', '-safe', '0', '-i', '/web/test/ASJServer/static/temp/filelist.txt', '-c', 'copy',
-             final_output],
-            check=True)
+            ['static/ffmpeg/ffmpeg6', '-f', 'concat', '-safe', '0', '-i', filelist_path, '-i', music_path,
+             '-c:v', 'copy', '-c:a', 'aac', '-b:a', '192k', '-movflags', '+faststart', '-shortest',
+             final_output_with_music],
+            check=True
+        )
+        video420acc = os.path.join(output_path, 'video420acc.mp4')
 
-        # 添加背景音乐
-        final_output_with_music = os.path.join(output_path, 'final_output_with_music.mp4')
-        subprocess.run(['ffmpeg', '-i', final_output, '-i', music_path, '-c:v', 'copy', '-c:a', 'aac', '-b:a', '192k',
-                        '-shortest', final_output_with_music], check=True)
+        subprocess.run(
+            ['static/ffmpeg/ffmpeg6', '-i', final_output_with_music, '-pix_fmt', 'yuv420p', video420acc],
+            check=True
+        )
 
         # 清理临时文件
         for video in video_files:
             os.remove(video)
-        os.remove('/web/test/ASJServer/static/temp/filelist.txt')
+        os.remove(filelist_path)
+        os.remove(final_output_with_music)
     except Exception as e:
         LOGGER.info(f'视频合成失败: {e}')
 

+ 2 - 2
Controller/DetectController.py

@@ -24,7 +24,7 @@ from pyfcm import FCMNotification
 
 from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, DETECT_PUSH_DOMAIN, \
     JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, \
-    BASE_DIR, APNS_MODE, SERVER_TYPE, LOGGER
+    BASE_DIR, APNS_MODE, SERVER_TYPE, LOGGER, PUSH_REDIS_ADDRESS
 from Model.models import Device_Info, Equipment_Info, UidSetModel, UidPushModel, SysMsgModel, \
     VodBucketModel
 from Object.ETkObject import ETkObject
@@ -315,7 +315,7 @@ class DetectControllerView(View):
 
     def do_delete_redis(self, uid, detect_interval=0):
         keyPattern = '{uid}*'.format(uid=uid)
-        redisObj = RedisObject()
+        redisObj = RedisObject(host=PUSH_REDIS_ADDRESS)
         keys = redisObj.get_keys(keyPattern)
         if keys:
             for key in keys:

+ 1 - 1
Controller/DetectControllerV2.py

@@ -306,7 +306,7 @@ class DetectControllerViewV2(View):
 
     def do_delete_redis(self, uid, detect_interval=0):
         keyPattern = '{uid}*'.format(uid=uid)
-        redisObj = RedisObject()
+        redisObj = RedisObject(host=PUSH_REDIS_ADDRESS)
         keys = redisObj.get_keys(keyPattern)
         if keys:
             for key in keys:

+ 6 - 1
Controller/EquipmentManagerV3.py

@@ -19,7 +19,7 @@ from Controller.UnicomCombo.UnicomComboController import UnicomComboView
 from Controller.UnicomCombo.WXTechController import WXTechControllerView
 from Model.models import Device_Info, UID_Bucket, UID_Preview, UidSetModel, UidChannelSetModel, \
     Device_User, iotdeviceInfoModel, UIDCompanySerialModel, UnicomDeviceInfo, CountryModel, \
-    DeviceCloudPhotoInfo, UidPushModel, ExperienceContextModel, LogModel, UserAudioVideoPush
+    DeviceCloudPhotoInfo, UidPushModel, ExperienceContextModel, LogModel, UserAudioVideoPush, UIDModel
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Service.CommonService import CommonService
@@ -159,6 +159,11 @@ class EquipmentManagerV3(View):
         device_user_qs = Device_User.objects.filter(userID=userID).values('username')
         if not device_user_qs.exists():
             return response.json(173)
+
+        uid_status = UIDModel.objects.filter(uid=UID).values('status').first()
+        if uid_status and uid_status['status'] == 0:
+            return response.json(10076)
+
         userName = device_user_qs[0]['username']
         main_exist = Device_Info.objects.filter(UID=UID)
         main_exist = main_exist.filter(~Q(vodPrimaryUserID='')).values('vodPrimaryUserID', 'vodPrimaryMaster')

+ 7 - 6
Controller/SerialNumberController.py

@@ -611,9 +611,15 @@ class SerialNumberView(View):
                 # 重置扫码记录
                 AppScannedSerial.objects.filter(serial=serial).delete()
 
+                # 异步调用客户代理平台同步序列号解绑UID
+                agent_thread = threading.Thread(target=AgentDeviceView.device_binding_or_unbinding,
+                                                args=(serial_number[0:9], 2))
+                agent_thread.start()
+
                 # 记录操作日志
                 ip = CommonService.get_ip_address(request)
                 content = json.loads(json.dumps(request_dict))
+                end_time = int(time.time())
                 log = {
                     'ip': ip,
                     'user_id': 1,
@@ -621,15 +627,10 @@ class SerialNumberView(View):
                     'time': now_time,
                     'content': json.dumps(content),
                     'url': 'serialNumber/detachUID',
-                    'operation': '序列号{}解绑uid: {}'.format(serial, uid),
+                    'operation': '序列号{}解绑uid{},执行时间{}秒'.format(serial, uid, end_time-now_time),
                 }
                 LogModel.objects.create(**log)
 
-                # 异步调用客户代理平台同步序列号解绑UID
-                agent_thread = threading.Thread(target=AgentDeviceView.device_binding_or_unbinding,
-                                                args=(serial_number[0:9], 2))
-                agent_thread.start()
-
             return response.json(0)
         except Exception as e:
             # 记录操作日志

+ 4 - 4
Controller/TimeAlbumController.py

@@ -32,11 +32,11 @@ class TimeAlbum(View):
         # 下载图片保存地址
 
         # 收集图片文件路径
-        image_files = ['/web/test/ASJServer/static/temp/image1.jpg', '/web/test/ASJServer/static/temp/image2.jpg',
-                       '/web/test/ASJServer/static/temp/image3.jpg', '/web/test/ASJServer/static/temp/image4.jpg',
-                       '/web/test/ASJServer/static/temp/image5.jpg']
+        image_files = ['static/temp/image1.jpg', 'static/temp/image2.jpg',
+                       'static/temp/image3.jpg', 'static/temp/image4.jpg',
+                       'static/temp/image5.jpg']
 
-        output_path = '/web/test/ASJServer/static/temp'
+        output_path = 'static/temp'
 
         # 调用 Celery 任务
         generate_video.delay(image_files, output_path)

+ 2 - 2
Object/RedisObject.py

@@ -8,8 +8,8 @@ from Ansjer.config import SERVER_HOST
 
 class RedisObject:
 
-    def __init__(self, db=0):
-        self.POOL = redis.ConnectionPool(host=SERVER_HOST, port=6379, db=db)
+    def __init__(self, db=0, host=SERVER_HOST):
+        self.POOL = redis.ConnectionPool(host=host, port=6379, db=db)
         self.CONN = redis.Redis(connection_pool=self.POOL)
 
     def set_data(self, key, val, expire=0):

+ 4 - 2
Object/ResponseObject.py

@@ -155,7 +155,8 @@ class ResponseObject(object):
             10072: 'This function has been disabled. Please contact the administrator',
             10073: 'The verification code has been sent, please pay attention to check',
             10074: 'Task queue processing, please try again later',
-            10075: 'Email subscription failed'
+            10075: 'Email subscription failed',
+            10076: 'Failed to add, please contact customer service'
         }
         data_cn = {
             0: '成功',
@@ -297,7 +298,8 @@ class ResponseObject(object):
             10072: '该功能已停用,请联系管理员',
             10073: '验证码已发送,请注意查收',
             10074: '任务队列处理中,请稍后再试',
-            10075: '邮件订阅失败'
+            10075: '邮件订阅失败',
+            10076: '添加失败,请联系客服'
         }
 
         msg = data_cn if self.lang == 'cn' or self.lang == 'zh-Hans' or self.lang == 'zh-Hant' else data_en