瀏覽代碼

定时更新指定版本配置信息2

guanhailong 2 年之前
父節點
當前提交
799bf51e3d
共有 1 個文件被更改,包括 4 次插入10 次删除
  1. 4 10
      Controller/Cron/CronTaskController.py

+ 4 - 10
Controller/Cron/CronTaskController.py

@@ -68,8 +68,7 @@ class CronDelDataView(View):
         @return:
         """
         try:
-            cursor = connection.cursor()
-            ucode_data = ('823C01552AA',
+            ucode_list = ('823C01552AA',
                           '823C01550AA',
                           '823C01850XA',
                           '730201350AA',
@@ -82,14 +81,9 @@ class CronDelDataView(View):
                           '72V201354AA',
                           '72V201355AA',
                           '72V201254AA')
-            sql1 = 'UPDATE `uid_set` SET is_human=1 WHERE ucode in {} AND is_human=0;'.format(ucode_data)
-            cursor.execute(sql1)
-            connection.commit()
-            sql2 = "UPDATE `uid_set` SET mobile_4g=1 WHERE ucode='72V201254AA' AND mobile_4g=0;"
-            cursor.execute(sql2)
-            connection.commit()
-            cursor.close()  # 执行完,关闭
-            connection.close()
+            UidSetModel.objects.filter(
+                Q(ucode__in=ucode_list, is_human=0) | Q(ucode='72V201254AA', mobile_4g=0)).update(is_human=1,
+                                                                                                  mobile_4g=1)
             return response.json(0)
         except Exception as e:
             return response.json(500, repr(e))