fix: 修改一些bug及模板
This commit is contained in:
parent
f80b196145
commit
c33ed1726c
|
@ -118,7 +118,6 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'):
|
||||||
try:
|
try:
|
||||||
conn_web = psycopg2.connect(
|
conn_web = psycopg2.connect(
|
||||||
"dbname={} user={} password={} host={} port={}".format('edn_cms', 'auditor', 'Lde78B3_cbma', '10.65.253.10', '54321'))
|
"dbname={} user={} password={} host={} port={}".format('edn_cms', 'auditor', 'Lde78B3_cbma', '10.65.253.10', '54321'))
|
||||||
cur_web = conn.cursor()
|
|
||||||
query_web = f"""
|
query_web = f"""
|
||||||
SELECT
|
SELECT
|
||||||
a_outer.id,
|
a_outer.id,
|
||||||
|
@ -146,10 +145,9 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'):
|
||||||
a_outer.ctime;
|
a_outer.ctime;
|
||||||
"""
|
"""
|
||||||
df_web = pd.read_sql_query(query_web, conn_web)
|
df_web = pd.read_sql_query(query_web, conn_web)
|
||||||
cur_web.close()
|
|
||||||
conn_web.close()
|
conn_web.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
# 追加总院数据来源
|
# 追加总院数据来源
|
||||||
for ind, row in df.iterrows():
|
for ind, row in df.iterrows():
|
||||||
|
@ -193,7 +191,7 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'):
|
||||||
# df_fx.at[ind, '供总院全年稿数'] = ((df['source'].str.contains(dw))&(df['gbiz']==zybiz)).sum()
|
# df_fx.at[ind, '供总院全年稿数'] = ((df['source'].str.contains(dw))&(df['gbiz']==zybiz)).sum()
|
||||||
df_fx.at[ind, '供总院全年专稿数'] = (
|
df_fx.at[ind, '供总院全年专稿数'] = (
|
||||||
(df['source'] == dw) & (df['gbiz'] == zybiz)).sum()
|
(df['source'] == dw) & (df['gbiz'] == zybiz)).sum()
|
||||||
df_fx.at[ind, '供总院全年网站专稿数'] = (
|
df_fx.at[ind, '供总院网站全年专稿数'] = (
|
||||||
(df_web['source'] == dw)).sum()
|
(df_web['source'] == dw)).sum()
|
||||||
df_fx.at[ind, '供总院全年组稿数'] = ((df['source'].str.contains(
|
df_fx.at[ind, '供总院全年组稿数'] = ((df['source'].str.contains(
|
||||||
dw) & (df['source'] != dw)) & (df['gbiz'] == zybiz)).sum()
|
dw) & (df['source'] != dw)) & (df['gbiz'] == zybiz)).sum()
|
||||||
|
@ -290,11 +288,11 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'):
|
||||||
sheet_web.cell(row=1, column=1, value=f'关于{year}年度中国建材总院新媒体更新情况明细表\n(网站)')
|
sheet_web.cell(row=1, column=1, value=f'关于{year}年度中国建材总院新媒体更新情况明细表\n(网站)')
|
||||||
ind_zyweb = 0
|
ind_zyweb = 0
|
||||||
for ind, row in df_web.iterrows():
|
for ind, row in df_web.iterrows():
|
||||||
sheet.cell(row=ind_zy+3, column=1, value=str(ind_zyweb+1))
|
sheet_web.cell(row=ind_zyweb+3, column=1, value=str(ind_zyweb+1))
|
||||||
sheet.cell(row=ind_zy+3, column=2, value=f'{row["pub_year"]}-{row["pub_month"]}-{row["pub_day"]}')
|
sheet_web.cell(row=ind_zyweb+3, column=2, value=f'{row["pub_year"]}-{row["pub_month"]}-{row["pub_day"]}')
|
||||||
sheet.cell(row=ind_zy+3, column=3, value=row['title'])
|
sheet_web.cell(row=ind_zyweb+3, column=3, value=row['title'])
|
||||||
sheet.cell(row=ind_zy+3, column=4, value=row['source'])
|
sheet_web.cell(row=ind_zyweb+3, column=4, value=row['source'])
|
||||||
sheet.cell(row=ind_zy+3, column=5, value=row['bankuai'])
|
sheet_web.cell(row=ind_zyweb+3, column=5, value=row['bankuai'])
|
||||||
ind_zyweb = ind_zyweb + 1
|
ind_zyweb = ind_zyweb + 1
|
||||||
cbma_path = os.path.join(BASE_DIR, f'summary/{year}年_总院文章.xlsx')
|
cbma_path = os.path.join(BASE_DIR, f'summary/{year}年_总院文章.xlsx')
|
||||||
workbook.save(cbma_path)
|
workbook.save(cbma_path)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue