12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- from .CalcBase import CalcBase
- from .DataStream import EMchPosmap as pos_map, span_days
- from .MerchantReader import MerchantReader
- from .algorithm import calc_morder_lack
- import logging
- logger = logging.getLogger('MerchantCalcBase')
- def detail_paths(reader: MerchantReader, tuple_pathes: dict, days: list):
- count = len(days)
- for mchid, tup in tuple_pathes.items():
- for _card_type, _spec in tup:
- detail_datas = reader.init_data(count)
- for i, day in enumerate(days):
- data = reader.read(day, mchid, _card_type, _spec)
- if data is not None:
- column_pos = i * 86400
- view = detail_datas[:, column_pos:column_pos + 86400]
- view += data
- yield mchid, _card_type, _spec, detail_datas
- def mch_detail_paths(reader: MerchantReader, tuple_pathes: dict, days: list):
- count = len(days)
- for mchid, tup in tuple_pathes.items():
- mch_datas = reader.init_data(count)
- for _card_type, _spec in tup:
- detail_datas = reader.init_data(count)
- for i, day in enumerate(days):
- data = reader.read(day, mchid, _card_type, _spec)
- if data is not None:
- column_pos = i * 86400
- view = detail_datas[:, column_pos:column_pos + 86400]
- view += data
- view = mch_datas[:, column_pos:column_pos + 86400]
- view += data
- yield mchid, _card_type, _spec, detail_datas
- yield mchid, None, None, mch_datas
- def mch_paths(reader: MerchantReader, tuple_pathes: dict, days: list):
- count = len(days)
- for mchid, tup in tuple_pathes.items():
- mch_datas = reader.init_data(count)
- for _card_type, _spec in tup:
- for i, day in enumerate(days):
- data = reader.read(day, mchid, _card_type, _spec)
- if data is not None:
- column_pos = i * 86400
- view = mch_datas[:, column_pos:column_pos + 86400]
- view += data
- yield mchid, None, None, mch_datas
- def allpathes(reader: MerchantReader, tuple_pathes: dict, days: list, spec=None):
- count = len(days)
- show_detail = True if len(list(tuple_pathes.keys())) == 1 else False
- if show_detail == False:
- all_datas = reader.init_data(count)
- else:
- all_datas = None
- for mchid, tup in tuple_pathes.items():
- add_mchid(mchid)
- mch_datas = reader.init_data(count)
- for _card_type, _spec in tup:
- if spec is not None and _spec != spec:
- continue
- if show_detail:
- detail_datas = reader.init_data(count)
- else:
- detail_datas = None
- for i, day in enumerate(days):
- data = reader.read(day, mchid, _card_type, _spec)
- if data is not None:
- column_pos = i * 86400
- view = mch_datas[:, column_pos:column_pos + 86400]
- view += data
- if show_detail:
- view = detail_datas[:, column_pos:column_pos + 86400]
- view += data
- if show_detail:
- yield mchid, _card_type, _spec, detail_datas
- if all_datas is not None:
- all_datas += mch_datas
- yield mchid, None, None, mch_datas
- if show_detail == False:
- yield 'all', None, None, all_datas
- class MerchantCalcBase(CalcBase):
- def _reader(self):
- return MerchantReader()
- pass
|