Пример #1
0
 def update_ftp_event_detail(ftp_event_id, event_name, event_desc, ftp_id,
                             data_path, file_name, interface_id, start_time,
                             end_time, date_time, interval_value,
                             old_status, new_status, user_id):
     """修改文件事件详情"""
     # 修改事件详情
     FtpEventModel.update_ftp_event_detail(db.etl_db, ftp_event_id,
                                           event_name, event_desc, ftp_id,
                                           data_path, file_name,
                                           interval_value, start_time,
                                           end_time, date_time, new_status,
                                           user_id)
     # 修改任务流依赖
     interface_id = interface_id.split(',')
     insert_data = []
     for item in interface_id:
         insert_data.append({
             'ftp_event_id': ftp_event_id,
             'interface_id': item
         })
     FtpEventModel.delete_file_event_interface(db.etl_db, ftp_event_id)
     FtpEventModel.add_file_event_interface(db.etl_db, insert_data)
     # 修改文件事件状态
     run_id = 'ftp_event_%s' % ftp_event_id
     minute = '*/%s' % interval_value
     hour = '%d-%d' % (start_time, end_time)
     # 新增调度
     # 仍失效
     if old_status == 0 and new_status == 0:
         pass
     # 新增 or 先新增后暂停
     elif old_status == 0 and new_status == 1 or old_status == 0 and new_status == 2:
         EventHandler.add_event(run_id, ftp_event_id, minute, hour)
     # 修改
     else:
         EventHandler.modify_event(run_id, ftp_event_id, minute, hour)
     # 先新增后暂停
     if old_status == 0 and new_status == 2:
         EventHandler.pause_job(run_id)
     # 暂停
     elif old_status == 1 and new_status == 2:
         EventHandler.pause_job(run_id)
     # 失效
     elif old_status == 1 and new_status == 0 or old_status == 2 and new_status == 0:
         EventHandler.remove_job(run_id)
     # 恢复
     elif old_status == 2 and new_status == 1:
         EventHandler.resume_job(run_id)
     return Response(ftp_event_id=ftp_event_id)
Пример #2
0
 def add_ftp_event_detail(event_name, event_desc, ftp_id, data_path,
                          file_name, interface_id, start_time, end_time,
                          date_time, interval_value, user_id):
     """新增文件事件详情"""
     # 新增事件详情
     ftp_event_id = FtpEventModel.add_ftp_event_detail(
         db.etl_db, event_name, event_desc, ftp_id, data_path, file_name,
         interval_value, start_time, end_time, date_time, user_id)
     # 新增调度
     run_id = 'ftp_event_%s' % ftp_event_id
     minute = '*/%s' % interval_value
     hour = '%d-%d' % (start_time, end_time)
     EventHandler.add_event(run_id, ftp_event_id, minute, hour)
     # 新增任务流依赖
     interface_id = interface_id.split(',')
     insert_data = []
     for item in interface_id:
         insert_data.append({
             'ftp_event_id': ftp_event_id,
             'interface_id': item
         })
     FtpEventModel.add_file_event_interface(db.etl_db, insert_data)
     return Response(ftp_event_id=ftp_event_id)