from Fetcher import Fetcher import re import numpy as np class UserFetcher(Fetcher): #0纬放所有数据,1纬放成功,2纬放失败 pos_map = { 'commit': 0, 'success': 1, 'fail': 2 } name_prefix = { 'nc_user_monitor_commit': 'commit', 'nc_user_monitor_success': 'success', 'nc_user_monitor_fail': 'fail' } def __init__(self): filename = '/var/www/html/data/stdata/user.hdf5' super().__init__(filename) pass def redis_name_prefix(self) -> dict: return self.name_prefix def parase(self, hfive, key, val, prefix,latest_time): items = re.split(r'-', key) if len(items) != 5: return True (mchid, quality, card_type, amount, time) = items pos = self.pos_map[f'{prefix}'] time = int(time) today = self.day_stamp(time) path = f'/{today}/{mchid}/{quality}/{card_type}/{amount}' if path not in hfive: dim = len(self.pos_map) hfive[path] = np.zeros((dim, 86400)) diff = time - today if diff < 0: print(diff) hfive[path][pos, diff] = val print(path, pos, diff, val, hfive[path][pos, diff]) if time > latest_time: return False else: return True pass pass