|
@@ -14,7 +14,7 @@ import logging
|
|
|
|
|
|
class MchDataCenter(object):
|
|
|
pos_map = {
|
|
|
- 'commit-succ': 0, 'notify-succ': 1
|
|
|
+ 'commit': 0, 'notify': 1
|
|
|
}
|
|
|
|
|
|
def __init__(self):
|
|
@@ -34,7 +34,6 @@ class MchDataCenter(object):
|
|
|
def prepare_data(self):
|
|
|
while True:
|
|
|
try:
|
|
|
- # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
|
|
|
pool = redis.ConnectionPool(host=self._mRHost, port=self._mRPort, db=0)
|
|
|
r = redis.Redis(connection_pool=pool)
|
|
|
|
|
@@ -43,12 +42,12 @@ class MchDataCenter(object):
|
|
|
else:
|
|
|
hfive = h5py.File(self._file_name, 'w')
|
|
|
|
|
|
- self.read_redis(hfive, r, 'nc_channel_monitor_commit', 'commit')
|
|
|
- self.read_redis(hfive, r, 'nc_channel_monitor_notify', 'notify')
|
|
|
+ self.read_redis(hfive, r, 'nc_user_monitor_commit', 'commit')
|
|
|
+ self.read_redis(hfive, r, 'nc_user_monitor_success', 'notify')
|
|
|
hfive.close()
|
|
|
|
|
|
- self.del_redis(r, 'nc_channel_monitor_commit')
|
|
|
- self.del_redis(r, 'nc_channel_monitor_notify')
|
|
|
+ self.del_redis(r, 'nc_user_monitor_commit')
|
|
|
+ self.del_redis(r, 'nc_user_monitor_success')
|
|
|
except Exception as ex:
|
|
|
print(ex)
|
|
|
finally:
|
|
@@ -65,8 +64,8 @@ class MchDataCenter(object):
|
|
|
items = re.split(r'-', key)
|
|
|
|
|
|
fdel = True
|
|
|
- if len(items) == 6:
|
|
|
- (stype, chname, quality, card_type, amount, time) = items
|
|
|
+ if len(items) == 5:
|
|
|
+ (mchid, quality, card_type, amount, time) = items
|
|
|
time = int(time)
|
|
|
if latest_time <= time:
|
|
|
fdel = False
|
|
@@ -86,22 +85,17 @@ class MchDataCenter(object):
|
|
|
|
|
|
def parase(self, hfive, text, val, prefix):
|
|
|
items = re.split(r'-', text)
|
|
|
- if len(items) != 6:
|
|
|
+ if len(items) != 5:
|
|
|
return False
|
|
|
|
|
|
- (stype, chname, quality, card_type, amount, time) = items
|
|
|
- if stype == 'succ':
|
|
|
- pos = self.pos_map[f'{prefix}-succ']
|
|
|
- elif stype == 'fail':
|
|
|
- pos = self.pos_map[f'{prefix}-fail']
|
|
|
- else:
|
|
|
- return False
|
|
|
+ (mchid, quality, card_type, amount, time) = items
|
|
|
+ pos = self.pos_map[f'{prefix}']
|
|
|
|
|
|
time = int(time)
|
|
|
today = self.day_stamp(time)
|
|
|
- path = f'/{today}/{chname}/{quality}/{card_type}/{amount}'
|
|
|
+ path = f'/{today}/{mchid}/{quality}/{card_type}/{amount}'
|
|
|
if path not in hfive:
|
|
|
- hfive[path] = np.zeros((5, 86400))
|
|
|
+ hfive[path] = np.zeros((2, 86400))
|
|
|
|
|
|
diff = time - today
|
|
|
if diff < 0:
|
|
@@ -336,4 +330,4 @@ class MchDataCenter(object):
|
|
|
return f"{path}:{count}/{all} = {ratio}%"
|
|
|
|
|
|
|
|
|
-dataCenter = DataCenter()
|
|
|
+dataCenter = MchDataCenter()
|