bug修改
This commit is contained in:
parent
ca6f90a29b
commit
fec659bdf4
|
@ -16,6 +16,7 @@ def add_file(db: Session, data: FileSechemas.UserFileCreate):
|
||||||
db.refresh(new_file)
|
db.refresh(new_file)
|
||||||
return new_file
|
return new_file
|
||||||
|
|
||||||
|
|
||||||
def file_query(db: Session, params: FileSechemas.UserFileQuery) -> (int, List[UserFile]):
|
def file_query(db: Session, params: FileSechemas.UserFileQuery) -> (int, List[UserFile]):
|
||||||
query = db.query(UserFile)
|
query = db.query(UserFile)
|
||||||
if params.md:
|
if params.md:
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from Utils.SqlAlchemyUtils import get_db_i
|
from Utils.SqlAlchemyUtils import get_db_i
|
||||||
from Models.PostModel import Post
|
from Models.PostModel import Post
|
||||||
from Models.DepartmentModel import Department
|
from Models.DepartmentModel import Department
|
||||||
|
@ -104,5 +106,53 @@ def load_daily():
|
||||||
email = db.query(User).filter_by(name=报送人).first().email
|
email = db.query(User).filter_by(name=报送人).first().email
|
||||||
department_id = d_name_dic[部门]
|
department_id = d_name_dic[部门]
|
||||||
post_id = post_dic[department_id][职务]
|
post_id = post_dic[department_id][职务]
|
||||||
db.add(Daily(type=报送类型,fill_user=email,title=标题,content=正文,post=post_id,department=department_id,daily_time=报送时间))
|
db.add(Daily(type=报送类型, fill_user=email, title=标题, content=正文, post=post_id, department=department_id,
|
||||||
|
daily_time=报送时间))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def load_user_data(db: Session):
|
||||||
|
dt = pd.read_excel("远东员工花名册(1).xlsx")
|
||||||
|
line_count = dt.shape[0]
|
||||||
|
user_list = []
|
||||||
|
post_list = []
|
||||||
|
dp_id_dic = {item.name: item.id for item in db.query(Department).all()}
|
||||||
|
dt = dt.fillna(value="")
|
||||||
|
for i in range(line_count):
|
||||||
|
row = dt.loc[i]
|
||||||
|
部门1 = row["部门"]
|
||||||
|
部门2 = row["部门2"]
|
||||||
|
职务1 = row["职务"]
|
||||||
|
职务2 = row["职务2"]
|
||||||
|
user_info = {
|
||||||
|
"email": row["邮箱"],
|
||||||
|
"name": row["姓名"],
|
||||||
|
"manage_departments": row["所看部门"].split(',') if row["所看部门"] else [],
|
||||||
|
"phone": row["移动电话"],
|
||||||
|
"department": [item for item in [部门1, 部门2] if item],
|
||||||
|
"post": [item for item in [[部门1, 职务1], [部门2, 职务2]] if item[0]]
|
||||||
|
}
|
||||||
|
post_list.extend(user_info["post"])
|
||||||
|
user_list.append(user_info)
|
||||||
|
# post_list.sort(key=lambda x: dp_id_dic[x[0]])
|
||||||
|
# db.query(Post).delete()
|
||||||
|
# for post in post_list:
|
||||||
|
# new_post = Post(name=post[1], belong=dp_id_dic[post[0]])
|
||||||
|
# db.add(new_post)
|
||||||
|
# db.commit()
|
||||||
|
dp_post_dic = {}
|
||||||
|
for item in db.query(Post).all():
|
||||||
|
if not dp_post_dic.get(item.belong):
|
||||||
|
dp_post_dic[item.belong] = {}
|
||||||
|
dp_post_dic[item.belong][item.name] = item.id
|
||||||
|
db.query(User).delete()
|
||||||
|
for user_info in user_list:
|
||||||
|
new_user = User()
|
||||||
|
new_user.email = user_info['email']
|
||||||
|
new_user.name = user_info['name']
|
||||||
|
new_user.manage_departments = ",".join([str(dp_id_dic[item]) for item in user_info['manage_departments']])
|
||||||
|
new_user.post = ",".join([str(dp_post_dic[dp_id_dic[item[0]]][item[1]]) for item in user_info['post']])
|
||||||
|
new_user.department = ",".join([str(dp_id_dic[item]) for item in user_info['department']])
|
||||||
|
new_user.phone = str(int(user_info['phone'])) if user_info['phone'] else None
|
||||||
|
db.add(new_user)
|
||||||
db.commit()
|
db.commit()
|
|
@ -29,6 +29,5 @@ class RedisPool:
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
redis_pool = RedisPool(host=REDIS_HOST, port=REDIS_PORT)
|
redis_pool = RedisPool(host=REDIS_HOST, port=REDIS_PORT)
|
||||||
redis_pool.connect()
|
redis_pool.connect()
|
||||||
|
|
|
@ -7,7 +7,7 @@ from typing import Literal, List, Any, Optional
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
user = "root"
|
user = "root"
|
||||||
password = "123456"
|
password = "12345"
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
db = 'daily'
|
db = 'daily'
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue