查询班主任学生停结课状态

#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
sys.path.append(r'e:\Desktop\新环境\DataMachine_for_timers\src')

from utils import mysqlhelper,emailhelper
from config import config
import re

mysqlinstance_tm_new_hfjy = mysqlhelper(**config.tm_new_hfjy)
mysqlinstance_tm_new_bidata = mysqlhelper(**config.tm_new_bidata)
mysqlinstance_dmart_bidata = mysqlhelper(**config.dmart_bidata)


# In[ ]:


#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2018-11-16 18:46
# @Author  : liupan
# @Email   : liupan010161@hfjy.com
# @File    : teacher_std_suspension_classes.py
# @Software: PyCharm

import sys
sys.path.append('../')

import os
file_path = os.path.dirname(os.path.realpath(__file__))  # 获取项目根目录
file_basename = os.path.basename(__file__)
father_path = os.path.abspath(os.path.dirname(file_path))

from utils import mysqlhelper,emailhelper
from config import config
import re

mysqlinstance_tm_new_hfjy = mysqlhelper(**config.tm_new_hfjy)
mysqlinstance_tm_new_bidata = mysqlhelper(**config.tm_new_bidata)
mysqlinstance_dmart_bidata = mysqlhelper(**config.dmart_bidata)


title = "查询班主任学生停结课数据"


def drop_sb(x):
    ILLEGAL_CHARACTERS_RE = re.compile(r'[\000-\010]|[\013-\014]|[\016-\037]|[\x90\x04]')
    x = ILLEGAL_CHARACTERS_RE.sub(r'', x)
    return x


def tssc():

    filenames = 'e:\Desktop\新环境\DataMachine_for_timers\src'
    df = mysqlinstance_tm_new_hfjy.get_df_loadfile(filenames)

    df['最后沟通内容'] = df['最后沟通内容'].astype(str)
    df['最后沟通内容'] = df['最后沟通内容'].apply(lambda x: drop_sb(x))

    subject = title
    receivers = ["yjiang@hfjy.com", "huzhen@hfjy.com", "liujing@hfjy.com", "wangxiling@hfjy.com", "Bonnie@hfjy.com",
                 "zhupanpan@hfjy.com", "chenhong@hfjy.com", "liuya@hfjy.com", "wujingyao@hfjy.com",
                 "sunnyfunfun@hfjy.com", "shenyuqing@hfjy.com", "yaochuanting2698@hfjy.com",
                 "baojunjing291@hfjy.com", "ouyangyiqin@hfjy.com", "xueguanshujuzu@hfjy.com", "Lion@hfjy.com",
                 "shixiaochuan007912@hfjy.com","guodenglian@hfjy.com","wuxiaoyan017418@hfjy.com","tianhaiyong@hfjy.com","wujian@hfjy.com"]
    emailhelper().send_dftoexcel(subject, receivers, dfs=df, sheets_name=title)
    return df



def center1(centers, df):
    df = df[df['班主任组别'].str.contains('第一集团军一中心')]
    subject = title + '{0}'.format(centers[0])
    receivers = [ 'zoujun@hfjy.com']
    emailhelper().send_dftoexcel(subject, receivers, dfs=df, sheets_name=title)



def center2(centers, df):
    df = df[df['班主任组别'].str.contains('第一集团军二中心')]
    subject = title + '{0}'.format(centers[1])
    receivers = [ 'yangtao1@hfjy.com']
    emailhelper().send_dftoexcel(subject, receivers, dfs=df, sheets_name=title)



def center3(centers, df):
    df = df[df['班主任组别'].str.contains('第一集团军三中心')]
    subject = title + '{0}'.format(centers[2])
    receivers = [ 'swfin@hfjy.com']
    emailhelper().send_dftoexcel(subject, receivers, dfs=df, sheets_name=title)


def center4(centers, df):
    df = df[df['班主任组别'].str.contains('第二集团军')]
    subject = title + '{0}'.format(centers[3])
    receivers = [ 'zhangying@hfjy.com']
    emailhelper().send_dftoexcel(subject, receivers, dfs=df, sheets_name=title)


def main():
    centers = ['第一集团军一中心', '第一集团军二中心', '第一集团军三中心', '第二集团军']
    # 获取数据
    df = tssc()

    # 邮件:一中心
    center1(centers, df)
    # 邮件:二中心
    center2(centers, df)
    # 邮件:三中心
    center3(centers, df)
    # 邮件:四中心
    center4(centers, df)


if __name__ == '__main__':
    main()

文档更新时间: 2019-08-19 11:56   作者:admin