Commit f490d04c authored by litaolemo's avatar litaolemo

update

parent 3d0c15bc
......@@ -7,7 +7,7 @@
import hashlib
import json
import pandas
import pymysql
import xlwt, datetime
import redis
......@@ -263,7 +263,8 @@ exposure_sql = """
SELECT
cl_id,
card_id,
transaction_type
FROM
(
SELECT
......@@ -327,12 +328,13 @@ for res in sql_res:
if int(card_id) in second_demands_tractate_dict:
# print(cl_id, second_demands_tag_dict[card_id])
for tag_id in second_demands_tractate_dict[int(card_id)]:
if tag_id in second_demands_id_count:
second_demands_id_count[tag_id][int(card_id)] = 1
if transaction_type not in second_demands_id_count:
second_demands_id_count[transaction_type] = {}
if tag_id in second_demands_id_count[transaction_type]:
second_demands_id_count[transaction_type][tag_id][int(card_id)] = 1
else:
second_demands_id_count[tag_id] = {}
second_demands_id_count[tag_id][int(card_id)] = 1
second_demands_id_count[transaction_type][tag_id] = {}
second_demands_id_count[transaction_type][tag_id][int(card_id)] = 1
if tag_id in transaction_second_demands_dict:
try:
......@@ -355,11 +357,13 @@ for res in sql_res:
if int(card_id) in tags_v3_tractate_dict:
# print(cl_id,projects_demands_tag_dict[cl_id])
for tag_id in tags_v3_tractate_dict[int(card_id)]:
if tag_id in projects_demands_id_count:
projects_demands_id_count[tag_id][int(card_id)] = 1
if transaction_type not in tags_v3_tractate_dict:
tags_v3_tractate_dict[transaction_type] = {}
if tag_id in projects_demands_id_count[transaction_type]:
projects_demands_id_count[transaction_type][tag_id][int(card_id)] = 1
else:
projects_demands_id_count[tag_id] = {}
projects_demands_id_count[tag_id][int(card_id)] = 1
projects_demands_id_count[transaction_type][tag_id] = {}
projects_demands_id_count[transaction_type][tag_id][int(card_id)] = 1
if tag_id in transaction_projects_demands_type:
try:
......@@ -381,16 +385,27 @@ second_demands_list = []
# time.sleep(10)
# print(second_demands_id_count)
# time.sleep(10)
second_demands_csv_list = []
projects_csv_list = []
for tag_id in second_demands_tag_count:
temp_dict = {
"tag_name": tag_id,
"device_count": second_demands_tag_count[tag_id],
"tractate_count": second_demands_count_dict.get(tag_id),
"exporsure_count": len(second_demands_id_count[tag_id]) if second_demands_id_count.get(tag_id) else 0,
# "exporsure_count": len(second_demands_id_count[tag_id]) if second_demands_id_count.get(tag_id) else 0,
}
print(temp_dict['tag_name'], temp_dict['tractate_count'], temp_dict['exporsure_count'], temp_dict['device_count'],transaction_second_demands_dict.get(tag_id))
for transaction_type in second_demands_id_count:
if second_demands_id_count[transaction_type].get(tag_id):
temp_dict[transaction_type] = len(second_demands_id_count[transaction_type][tag_id])
else:
temp_dict[transaction_type] = 0
second_demands_csv_list.append(temp_dict)
print(temp_dict)
second_demands_data = pandas.DataFrame(second_demands_csv_list)
second_demands_data.to_csv("./second_demands.csv",encoding='gb18030')
# print(temp_dict['tag_name'], temp_dict['tractate_count'], temp_dict['exporsure_count'], temp_dict['device_count'],transaction_second_demands_dict.get(tag_id))
# print(temp_dict)
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
# print("error" , second_demands_id_count[tag_id])
......@@ -412,13 +427,31 @@ for tag_id in projects_demands_tag_count:
"tag_name": tag_id,
"device_count": projects_demands_tag_count[tag_id],
"tractate_count": tags_v3_count_dict.get(tag_id),
"exporsure_count": len(projects_demands_id_count[tag_id]) if projects_demands_id_count.get(tag_id) else 0,
# "exporsure_coun/t": len(projects_demands_id_count[tag_id]) if projects_demands_id_count.get(tag_id) else 0,
}
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
for transaction_type in projects_demands_id_count:
if projects_demands_id_count[transaction_type].get(tag_id):
temp_dict[transaction_type] = len(projects_demands_id_count[transaction_type][tag_id])
else:
temp_dict[transaction_type] = 0
projects_csv_list.append(temp_dict)
print(temp_dict)
projects_data = pandas.DataFrame(projects_csv_list)
projects_data.to_csv("./projects.csv", encoding='gb18030')
from crawler.maintenance.func_send_email_with_file import send_file_email
send_file_email("", '', sender="litao@igengmei.com", email_group=["litao@igengmei.com"], email_msg_body_str="test",
title_str="test", cc_group=["litao@igengmei.com"], file="/srv/apps/meta_base_code/second_demands.csv")
send_file_email("", '', sender="litao@igengmei.com", email_group=["litao@igengmei.com"], email_msg_body_str="test",
title_str="test", cc_group=["litao@igengmei.com"], file="/srv/apps/meta_base_code/projects.csv")
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
# print("error" , projects_demands_id_count[tag_id])
print(temp_dict['tag_name'], temp_dict['tractate_count'], temp_dict['exporsure_count'], temp_dict['device_count'],transaction_projects_demands_type.get(tag_id))
# print(temp_dict['tag_name'], temp_dict['tractate_count'], temp_dict['exporsure_count'], temp_dict['device_count'],transaction_projects_demands_type.get(tag_id))
# print(2)
# for tag_id in tags_v3_count_dict:
# if tag_id not in projects_demands_tag_count:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment