Browse Source

部分日志信息进行删除了(挪到了CommonFunction.py中),完成了logger信息加上了策略信息和account_id.

liyuyi@c-top.com.cn 4 years ago
parent
commit
5904c554fa
1 changed files with 42 additions and 82 deletions
  1. 42 82
      ai_time_task_creative_handler.py

+ 42 - 82
ai_time_task_creative_handler.py

@@ -52,13 +52,11 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                                                  url=get_app_detail_url,
                                                  url=get_app_detail_url,
                                                  app_id=app_id)
                                                  app_id=app_id)
                     if app_id_info['code'] != 0:
                     if app_id_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s,the res of get_app_detail is %s' %
-                                    (account_id, app_id, app_id_info['message']))
                         continue
                         continue
 
 
                     # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id,没有则设置 campaign_name
                     # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id,没有则设置 campaign_name
                     app_version = app_id_info['data'].get('appVersion', 'error')
                     app_version = app_id_info['data'].get('appVersion', 'error')
-                    track_url = app_id_info['data'].get('trackUrl','error')
+                    track_url = app_id_info['data'].get('trackUrl', 'error')
 
 
                     start_time = (datetime.date.today()).strftime('%Y-%m-%d %H:%M:%S')
                     start_time = (datetime.date.today()).strftime('%Y-%m-%d %H:%M:%S')
                     end_time = (datetime.datetime.now()).strftime('%Y-%m-%d %H:%M:%S')
                     end_time = (datetime.datetime.now()).strftime('%Y-%m-%d %H:%M:%S')
@@ -80,10 +78,6 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                                                                 start_time=missing_video_start_time,
                                                                 start_time=missing_video_start_time,
                                                                 end_time=missing_video_end_time,
                                                                 end_time=missing_video_end_time,
                                                                 app_version='all')
                                                                 app_version='all')
-                    if general_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of general_video_info is %s' %
-                                    (account_id, app_id, general_video_info['message']))
-
                     # 4、获取app_id对应的视频1个
                     # 4、获取app_id对应的视频1个
                     special_video_info = get_missing_video_info(account_id=account_id,
                     special_video_info = get_missing_video_info(account_id=account_id,
                                                                 cnt=1,
                                                                 cnt=1,
@@ -91,10 +85,6 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                                                                 start_time=missing_video_start_time,
                                                                 start_time=missing_video_start_time,
                                                                 end_time=missing_video_end_time,
                                                                 end_time=missing_video_end_time,
                                                                 app_version=app_version)
                                                                 app_version=app_version)
-                    if special_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of special_video_info is %s' %
-                                    (account_id, app_id, special_video_info['message']))
-
                     # 5、video_info 合并
                     # 5、video_info 合并
                     full_video_info = []
                     full_video_info = []
                     if general_video_info['code'] == 0:
                     if general_video_info['code'] == 0:
@@ -116,9 +106,9 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                                                         app_id=app_id,
                                                         app_id=app_id,
                                                         click_track_url=track_url)
                                                         click_track_url=track_url)
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("account_id=%s, app_id=%s, ai策略的返回信息:%s" % (account_id, app_id, request))
+                        logger.info("account_id=%s, app_id=%s, 补充遗漏素材,ai策略的返回信息:%s" % (account_id, app_id, request))
                         app_id_cnt += 1
                         app_id_cnt += 1
-                    if app_id_cnt >= 50:
+                    if app_id_cnt >= 100:
                         break
                         break
                 self.write(json.dumps({"message": "account_id=%s, 多应用的补充遗漏素材请求已走完!" % account_id}))
                 self.write(json.dumps({"message": "account_id=%s, 多应用的补充遗漏素材请求已走完!" % account_id}))
                 self.flush()
                 self.flush()
@@ -129,9 +119,9 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                                                     missing_video_start_time,
                                                     missing_video_start_time,
                                                     missing_video_end_time)
                                                     missing_video_end_time)
                 if video_info['code'] != 0:
                 if video_info['code'] != 0:
-                    logger.info("the res of video is %s" % video_info['message'])
-                    logger.info("没有获取到视频,不发送ai策略请求!")
-                    self.write(json.dumps({"message": "没有获取到视频,不发送ai策略请求!"}))
+                    logger.info("account_id = %s,补充历史遗漏素材,没有获取到视频,不发送ai策略请求!" % account_id)
+                    self.write(json.dumps({"account_id": account_id,
+                                           "message": "补充历史遗漏素材,没有获取到视频,不发送ai策略请求!"}))
                     self.flush()
                     self.flush()
                 else:
                 else:
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
@@ -148,7 +138,7 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                                                         ai_strategy_remark="补充遗漏素材",
                                                         ai_strategy_remark="补充遗漏素材",
                                                         name_replace="补充遗漏素材")
                                                         name_replace="补充遗漏素材")
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("ai策略的返回信息:%s" % request)
+                        logger.info("account_id = %s, 补充遗漏素材,ai策略的返回信息:%s" % (account_id, request))
                         self.write(json.dumps(request))
                         self.write(json.dumps(request))
                         self.flush()
                         self.flush()
         except Exception:
         except Exception:
@@ -187,8 +177,6 @@ class AiAutoCreative(tornado.web.RequestHandler):
                                                  url=get_app_detail_url,
                                                  url=get_app_detail_url,
                                                  app_id=app_id)
                                                  app_id=app_id)
                     if app_id_info['code'] != 0:
                     if app_id_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s,the res of get_app_detail is %s' %
-                                    (account_id, app_id, app_id_info['message']))
                         continue
                         continue
 
 
                     # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id,没有则设置 campaign_name
                     # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id,没有则设置 campaign_name
@@ -212,18 +200,10 @@ class AiAutoCreative(tornado.web.RequestHandler):
                     general_video_info = get_new_video_info(account_id=account_id,
                     general_video_info = get_new_video_info(account_id=account_id,
                                                             url=get_new_video_url,
                                                             url=get_new_video_url,
                                                             app_version='all')
                                                             app_version='all')
-                    if general_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of general_video_info is %s' %
-                                    (account_id, app_id, general_video_info['message']))
-
-                    # 4、获取app_id对应的视频
+                    # 4、获取app_id对应的特定视频
                     special_video_info = get_new_video_info(account_id=account_id,
                     special_video_info = get_new_video_info(account_id=account_id,
                                                             url=get_new_video_url,
                                                             url=get_new_video_url,
                                                             app_version=app_version)
                                                             app_version=app_version)
-                    if special_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of special_video_info is %s' %
-                                    (account_id, app_id, special_video_info['message']))
-
                     # 5、video_info 合并
                     # 5、video_info 合并
                     full_video_info = []
                     full_video_info = []
                     if general_video_info['code'] == 0:
                     if general_video_info['code'] == 0:
@@ -245,9 +225,9 @@ class AiAutoCreative(tornado.web.RequestHandler):
                                                         app_id=app_id,
                                                         app_id=app_id,
                                                         click_track_url=track_url)
                                                         click_track_url=track_url)
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("account_id=%s, app_id=%s, ai策略的返回信息:%s" % (account_id, app_id, request))
+                        logger.info("account_id=%s, app_id=%s, 素材自动上新,ai策略的返回信息:%s" % (account_id, app_id, request))
                     else:
                     else:
-                        logger.info("account_id=%s, app_id=%s, 没有获取到视频,不发送ai策略请求!" % (account_id, app_id))
+                        logger.info("account_id=%s, app_id=%s, 素材自动上新, 没有获取到视频,不发送ai策略请求!" % (account_id, app_id))
 
 
                 self.write(json.dumps({"message": "account_id=%s, 多应用的素材自动上新请求已走完!" % account_id}))
                 self.write(json.dumps({"message": "account_id=%s, 多应用的素材自动上新请求已走完!" % account_id}))
                 self.flush()
                 self.flush()
@@ -327,8 +307,6 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                                                  url=get_app_detail_url,
                                                  url=get_app_detail_url,
                                                  app_id=app_id)
                                                  app_id=app_id)
                     if app_id_info['code'] != 0:
                     if app_id_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s,the res of get_app_detail is %s' %
-                                    (account_id, app_id, app_id_info['message']))
                         continue
                         continue
 
 
                     # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id,没有则设置 campaign_name
                     # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id,没有则设置 campaign_name
@@ -357,10 +335,6 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                                                             end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                             end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                             cnt=1,
                                                             cnt=1,
                                                             app_version='all')
                                                             app_version='all')
-                    if general_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of general_video_info is %s' %
-                                    (account_id, app_id, general_video_info['message']))
-
                     # 4、获取app_id对应的1个视频
                     # 4、获取app_id对应的1个视频
                     special_video_info = get_top_video_info(account_id=account_id,
                     special_video_info = get_top_video_info(account_id=account_id,
                                                             url=get_high_quality_video_url,
                                                             url=get_high_quality_video_url,
@@ -370,9 +344,6 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                                                             end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                             end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                             cnt=1,
                                                             cnt=1,
                                                             app_version=app_version)
                                                             app_version=app_version)
-                    if special_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of special_video_info is %s' %
-                                    (account_id, app_id, special_video_info['message']))
 
 
                     # 5、video_info 合并
                     # 5、video_info 合并
                     full_video_info = []
                     full_video_info = []
@@ -395,9 +366,9 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                                                         app_id=app_id,
                                                         app_id=app_id,
                                                         click_track_url=track_url)
                                                         click_track_url=track_url)
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("account_id=%s, app_id=%s, ai策略的返回信息:%s" % (account_id, app_id, request))
+                        logger.info("account_id=%s, app_id=%s, 高质量素材复建,ai策略的返回信息:%s" % (account_id, app_id, request))
                         app_id_cnt += 1
                         app_id_cnt += 1
-                    if app_id_cnt >= 50:
+                    if app_id_cnt >= 100:
                         break
                         break
                 self.write(json.dumps({"message": "account_id=%s, 多应用的高质量素材复建请求已走完!" % account_id}))
                 self.write(json.dumps({"message": "account_id=%s, 多应用的高质量素材复建请求已走完!" % account_id}))
                 self.flush()
                 self.flush()
@@ -408,15 +379,16 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                                                 datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                 datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                 get_high_quality_video_url)
                                                 get_high_quality_video_url)
                 if video_info['code'] != 0:
                 if video_info['code'] != 0:
-                    logger.info("the res of video is %s" % video_info['message'])
-                    logger.info("没有获取到视频,不发送ai策略请求!")
-                    self.write(json.dumps({"message": "没有获取到视频,不发送ai策略请求!"}))
+                    logger.info("account_id = %s, 高质量素材复建,没有获取到视频,不发送ai策略请求!" % account_id)
+                    self.write(json.dumps({"account_id": account_id,
+                                           "message": "高质量素材复建,没有获取到视频,不发送ai策略请求!"}))
                     self.flush()
                     self.flush()
                 else:
                 else:
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                     if (campaign_name is None) or (group_name is None):
                     if (campaign_name is None) or (group_name is None):
-                        logger.info("没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!")
-                        self.write(json.dumps({"message": "没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!"}))
+                        logger.error("account_id = %s, 没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!" % account_id)
+                        self.write(json.dumps({"account_id": account_id,
+                                               "message": "没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!"}))
                         self.flush()
                         self.flush()
                     else:
                     else:
                         request_data = get_request_data(account_id=account_id,
                         request_data = get_request_data(account_id=account_id,
@@ -427,7 +399,7 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                                                         ai_strategy_remark="高质量素材复建",
                                                         ai_strategy_remark="高质量素材复建",
                                                         name_replace="高质量素材")
                                                         name_replace="高质量素材")
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("ai策略的返回信息:%s" % request)
+                        logger.info("account_id = %s, 高质量素材复建,ai策略的返回信息:%s" % (account_id, request))
                         self.write(json.dumps(request))
                         self.write(json.dumps(request))
                         self.flush()
                         self.flush()
         except Exception:
         except Exception:
@@ -507,8 +479,6 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
                                                      url=get_app_detail_url,
                                                      url=get_app_detail_url,
                                                      app_id=app_id)
                                                      app_id=app_id)
                         if app_id_info['code'] != 0:
                         if app_id_info['code'] != 0:
-                            logger.info('account_id=%s, app_id=%s,the res of get_app_detail is %s' %
-                                        (account_id, app_id, app_id_info['message']))
                             continue
                             continue
 
 
                         # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id, 没有则设置 campaign_name
                         # 2、依据 appVersion 的值,来判断当天是否已经有对应的计划,如果有则获取 campaign_id, 没有则设置 campaign_name
@@ -537,8 +507,6 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
                                                                 cnt=1,
                                                                 cnt=1,
                                                                 app_version=app_version)
                                                                 app_version=app_version)
                         if special_video_info['code'] != 0:
                         if special_video_info['code'] != 0:
-                            logger.info('account_id=%s, app_id=%s, the res of special_video_info is %s' %
-                                        (account_id, app_id, special_video_info['message']))
                             continue
                             continue
 
 
                         # 6、拼装request_data,调用ai_strategy_request_parse方法
                         # 6、拼装request_data,调用ai_strategy_request_parse方法
@@ -554,7 +522,7 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
                                                         app_id=app_id,
                                                         app_id=app_id,
                                                         click_track_url=track_url)
                                                         click_track_url=track_url)
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("account_id=%s, app_id=%s, ai策略的返回信息:%s" % (account_id, app_id, request))
+                        logger.info("account_id=%s, app_id=%s, 用高质量素材补满创意,ai策略的返回信息:%s" % (account_id, app_id, request))
                         app_id_cnt += 1
                         app_id_cnt += 1
                         if app_id_cnt >= needed_app_id_cnt:
                         if app_id_cnt >= needed_app_id_cnt:
                             break
                             break
@@ -574,22 +542,22 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
                             campaign_id = getattr(row, 'campaign_id')
                             campaign_id = getattr(row, 'campaign_id')
                             break
                             break
 
 
-
                     video_info = get_top_video_info(account_id,
                     video_info = get_top_video_info(account_id,
                                                     video_cnt,
                                                     video_cnt,
                                                     (now + datetime.timedelta(days=-2*high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
                                                     (now + datetime.timedelta(days=-2*high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
                                                     (now + datetime.timedelta(days=-high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
                                                     (now + datetime.timedelta(days=-high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
                                                     get_high_quality_video_url)
                                                     get_high_quality_video_url)
                     if video_info['code'] != 0:
                     if video_info['code'] != 0:
-                        logger.info("the res of video is %s" % video_info['message'])
-                        logger.info("没有获取到视频,不发送ai策略请求!")
-                        self.write(json.dumps({"message": "没有获取到视频,不发送ai策略请求!"}))
+                        logger.info("account_id = %s, 历史高质量素材填满, 没有获取到视频,不发送ai策略请求!" % account_id)
+                        self.write(json.dumps({"account_id": account_id,
+                                               "message": "历史高质量素材填满, 没有获取到视频,不发送ai策略请求!"}))
                         self.flush()
                         self.flush()
                     else:
                     else:
                         campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                         campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                         if (campaign_name is None) or (group_name is None):
                         if (campaign_name is None) or (group_name is None):
-                            logger.info("没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!")
-                            self.write(json.dumps({"message": "没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!"}))
+                            logger.info("account_id = %s, 没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!" % account_id)
+                            self.write(json.dumps({"account_id": account_id,
+                                                   "message": "没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!"}))
                             self.flush()
                             self.flush()
                         else:
                         else:
                             request_data = get_request_data(account_id=account_id,
                             request_data = get_request_data(account_id=account_id,
@@ -600,7 +568,7 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
                                                             ai_strategy_remark="用高质量素材补满创意",
                                                             ai_strategy_remark="用高质量素材补满创意",
                                                             name_replace="高质量素材")
                                                             name_replace="高质量素材")
                             request = ai_strategy_request_parse(request_data)
                             request = ai_strategy_request_parse(request_data)
-                            logger.info("ai策略的返回信息:%s" % request)
+                            logger.info("account_id = %s, 用高质量素材补满创意,ai策略的返回信息:%s" % (account_id, request))
                             self.write(json.dumps(request))
                             self.write(json.dumps(request))
                             self.flush()
                             self.flush()
         except Exception:
         except Exception:
@@ -655,8 +623,6 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
                                                  url=get_app_detail_url,
                                                  url=get_app_detail_url,
                                                  app_id=app_id)
                                                  app_id=app_id)
                     if app_id_info['code'] != 0:
                     if app_id_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of get_app_detail is %s' %
-                                    (account_id, app_id, app_id_info['message']))
                         continue
                         continue
 
 
                     app_version = app_id_info['data'].get('appVersion', 'error')
                     app_version = app_id_info['data'].get('appVersion', 'error')
@@ -672,8 +638,6 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
                                                             cnt=5,
                                                             cnt=5,
                                                             app_version=app_version)
                                                             app_version=app_version)
                     if special_video_info['code'] != 0:
                     if special_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of special_video_info is %s' %
-                                    (account_id, app_id, special_video_info['message']))
                         continue
                         continue
 
 
                     # 3、拼装request_data,调用ai_strategy_request_parse方法
                     # 3、拼装request_data,调用ai_strategy_request_parse方法
@@ -689,7 +653,7 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
                                                     app_id=app_id,
                                                     app_id=app_id,
                                                     click_track_url=track_url)
                                                     click_track_url=track_url)
                     request = ai_strategy_request_parse(request_data)
                     request = ai_strategy_request_parse(request_data)
-                    logger.info("account_id=%s, app_id=%s, ai策略的返回信息:%s" % (account_id, app_id, request))
+                    logger.info("account_id=%s, app_id=%s, 程序化高质量素材,ai策略的返回信息:%s" % (account_id, app_id, request))
                     app_id_cnt += 1
                     app_id_cnt += 1
                     if app_id_cnt >= 30:
                     if app_id_cnt >= 30:
                         break
                         break
@@ -703,15 +667,16 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
                                                 datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                 datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                 get_high_quality_video_url)
                                                 get_high_quality_video_url)
                 if video_info['code'] != 0:
                 if video_info['code'] != 0:
-                    logger.info("the res of video is %s" % video_info['message'])
-                    logger.info("没有获取到视频,不发送ai策略请求!")
-                    self.write(json.dumps({"message": "没有获取到视频,不发送ai策略请求!"}))
+                    logger.info("account_id = %s, 程序化高质量素材,没有获取到视频,不发送ai策略请求!" % account_id)
+                    self.write(json.dumps({"account_id": account_id,
+                                           "message": "没有获取到视频,不发送ai策略请求!"}))
                     self.flush()
                     self.flush()
                 else:
                 else:
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                     if (campaign_name is None) or (group_name is None):
                     if (campaign_name is None) or (group_name is None):
-                        logger.info("没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!")
-                        self.write(json.dumps({"message": "没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!"}))
+                        logger.info("account_id = %s, 没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!" % account_id)
+                        self.write(json.dumps({"account_id": account_id,
+                                               "message": "没有获取到广告计划命名规则 或 广告组命名规则,不发送ai策略请求!"}))
                         self.flush()
                         self.flush()
                     else:
                     else:
                         request_data = get_request_data(account_id=account_id,
                         request_data = get_request_data(account_id=account_id,
@@ -723,7 +688,7 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
                                                         name_replace="程序化高质量素材",
                                                         name_replace="程序化高质量素材",
                                                         unit_type=7)
                                                         unit_type=7)
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("ai策略的返回信息:%s" % request)
+                        logger.info("account_id = %s, 程序化高质量素材, ai策略的返回信息:%s" % (account_id, request))
                         self.write(json.dumps(request))
                         self.write(json.dumps(request))
                         self.flush()
                         self.flush()
         except Exception:
         except Exception:
@@ -734,7 +699,7 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
 
 
 class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
 class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
     """
     """
-    使用2天内 创意数关联小于10(当天创意关联数小于10的,150个素材)的素材创建程序化创意
+    使用N天内 创意数关联小于M个(如当天创意关联数小于10的,150个素材)的素材创建程序化创意
     计划名称--新素材程序化
     计划名称--新素材程序化
     timeTask: 每天上午10点执行 --(0 0 10 * * ?)
     timeTask: 每天上午10点执行 --(0 0 10 * * ?)
     """
     """
@@ -762,8 +727,6 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                                                  url=get_app_detail_url,
                                                  url=get_app_detail_url,
                                                  app_id=app_id)
                                                  app_id=app_id)
                     if app_id_info['code'] != 0:
                     if app_id_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of get_app_detail is %s' %
-                                    (account_id, app_id, app_id_info['message']))
                         continue
                         continue
 
 
                     app_version = app_id_info['data'].get('appVersion', 'error')
                     app_version = app_id_info['data'].get('appVersion', 'error')
@@ -772,7 +735,7 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                     # 2、获取特定视频
                     # 2、获取特定视频
                     special_video_info = get_history_video_info(account_id=account_id,
                     special_video_info = get_history_video_info(account_id=account_id,
                                                                 url=get_history_video_url,
                                                                 url=get_history_video_url,
-                                                                start_time=(datetime.datetime.now() + datetime.timedelta(days=-200)).
+                                                                start_time=(datetime.datetime.now() + datetime.timedelta(days=-60)).
                                                                 strftime("%Y-%m-%d %H:%M:%S"),
                                                                 strftime("%Y-%m-%d %H:%M:%S"),
                                                                 end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                                 end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                                 video_cnt=5,
                                                                 video_cnt=5,
@@ -780,8 +743,6 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                                                                 app_version=app_version
                                                                 app_version=app_version
                                                                 )
                                                                 )
                     if special_video_info['code'] != 0:
                     if special_video_info['code'] != 0:
-                        logger.info('account_id=%s, app_id=%s, the res of special_video_info is %s' %
-                                    (account_id, app_id, special_video_info['message']))
                         continue
                         continue
 
 
                     # 3、拼装request_data,调用ai_strategy_request_parse方法
                     # 3、拼装request_data,调用ai_strategy_request_parse方法
@@ -797,7 +758,7 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                                                     app_id=app_id,
                                                     app_id=app_id,
                                                     click_track_url=track_url)
                                                     click_track_url=track_url)
                     request = ai_strategy_request_parse(request_data)
                     request = ai_strategy_request_parse(request_data)
-                    logger.info("account_id=%s, app_id=%s, ai策略的返回信息:%s" % (account_id, app_id, request))
+                    logger.info("account_id=%s, app_id=%s, 程序化上新素材,ai策略的返回信息:%s" % (account_id, app_id, request))
                     app_id_cnt += 1
                     app_id_cnt += 1
                     if app_id_cnt >= 30:
                     if app_id_cnt >= 30:
                         break
                         break
@@ -807,15 +768,14 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
             else:
             else:
                 video_info = get_history_video_info(account_id=account_id,
                 video_info = get_history_video_info(account_id=account_id,
                                                     url=get_history_video_url,
                                                     url=get_history_video_url,
-                                                    start_time=(datetime.datetime.now() + datetime.timedelta(days=-2)).
+                                                    start_time=(datetime.datetime.now() + datetime.timedelta(days=-7)).
                                                     strftime("%Y-%m-%d %H:%M:%S"),
                                                     strftime("%Y-%m-%d %H:%M:%S"),
                                                     end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                     end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
                                                     video_cnt=programme_new_video_cnt,
                                                     video_cnt=programme_new_video_cnt,
                                                     related_creative_max_cnt=related_creative_max_cnt)
                                                     related_creative_max_cnt=related_creative_max_cnt)
                 if video_info['code'] != 0:
                 if video_info['code'] != 0:
-                    logger.info("the res of video is %s" % video_info['message'])
-                    logger.info("没有获取到视频,不发送ai策略请求!")
-                    self.write(json.dumps({"message": "没有获取到视频,不发送ai策略请求!"}))
+                    self.write(json.dumps({"account_id": account_id,
+                                           "message": "程序化上新素材,没有获取到视频,不发送ai策略请求!"}))
                     self.flush()
                     self.flush()
                 else:
                 else:
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
                     campaign_name, group_name = get_campaign_and_group_name_rule(account_id)
@@ -833,7 +793,7 @@ class AiProgramCreativeNewMaterial(tornado.web.RequestHandler):
                                                         name_replace="程序化上新素材",
                                                         name_replace="程序化上新素材",
                                                         unit_type=7)
                                                         unit_type=7)
                         request = ai_strategy_request_parse(request_data)
                         request = ai_strategy_request_parse(request_data)
-                        logger.info("ai策略的返回信息:%s" % request)
+                        logger.info("account_id = %s, 程序化上新素材,ai策略的返回信息:%s" % (account_id, request))
                         self.write(json.dumps(request))
                         self.write(json.dumps(request))
                         self.flush()
                         self.flush()
         except Exception:
         except Exception: