import json, os, time, collections

P = '/Users/liuxinyuan/Desktop/Hermes输出-工作类/数据/mcp_orders_input.json'
d = json.load(open(P, encoding='utf-8'))
print('type:', type(d).__name__, '| n =', len(d))
print('size %.1f KB' % (os.path.getsize(P) / 1024.0),
      '| mtime', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.path.getmtime(P))))
print('keys:', list(d[0].keys()))
months = collections.Counter(str(o.get('创建时间') or '')[:7] for o in d)
print('创建时间月份分布:', sorted(months.items()))
amt = sum(float(o.get('金额') or 0) for o in d)
print('金额合计 = %.2f 元' % amt)
print('金额>0 单数:', sum(1 for o in d if float(o.get('金额') or 0) > 0))
print('无单号:', sum(1 for o in d if not o.get('单据编号')))
print('无客户:', sum(1 for o in d if not o.get('购货单位#')))
print('无创建者:', sum(1 for o in d if not o.get('创建者')))
print('无销售部门:', sum(1 for o in d if not o.get('销售部门')))
print('最早/最晚:', min(str(o.get('创建时间') or '') for o in d), max(str(o.get('创建时间') or '') for o in d))
print('创建者 TOP10:', collections.Counter(o.get('创建者') for o in d).most_common(10))
