修改问题

duizhaopin
13507605001 2 years ago
parent 1ea822c8fa
commit 1e55945896

@ -93,14 +93,11 @@ def get_warning_list():
key_word=seach_word,
object_type=object_type
)
if warning_list:
data = {
"total_count": page_param.totalRecords,
"data_list": Utils.msyql_table_model(warning_list)
}
return jsonify(Utils.true_return(data=data))
else:
return jsonify(Utils.false_return(msg='获取预警信息列表失败'))
data = {
"total_count": page_param.totalRecords,
"data_list": Utils.msyql_table_model(warning_list)
}
return jsonify(Utils.true_return(data=data))
# 修改预警状态根据预警id进行
@ -113,7 +110,7 @@ def update_warning_type():
# obj.object_type = 2
obj.solve_date= Utils.get_str_datetime()
obj.solve_user_id = g.current_user.user_id
obj.solve_user_name = g.current_user.user_name
obj.solve_user_name = g.current_user.real_name
obj.is_solve=1
BllWarning().update(obj)

@ -34,6 +34,14 @@ def get_user_power_list():
return jsonify(Utils.true_return(data=data_list))
return jsonify(Utils.false_return(msg="用户id不能为空"))
# 获取用户是否用用户管理权限
@power_router.route("/get_user_manage_auth", methods=["POST"])
@token_auth.login_required
def user_usermanage_auth():
user_info = g.current_user
data = BllModuleRelation().get_user_manage_auth(user_info)
return jsonify(Utils.true_return(data=data))
# 分配用户权限
@power_router.route("/add_user_power", methods=["GET", "POST"])

@ -26,7 +26,7 @@ def user_login():
if user_obj:
return jsonify(Utils.true_return(msg="登陆成功", data={"token":user_obj, "user_info": Utils.to_dict(user_info)}))
else:
return jsonify(Utils.false_return(status=201, msg="登陆失败"))
return jsonify(Utils.false_return(status=201, msg="账号或密码输入有误!"))
# 修改密码,根据token获取用户信息接受老密码进行校验新密码写入
@user_router.route("/update_password", methods=["POST"])
@ -73,6 +73,9 @@ def get_user_info_list():
@token_auth.login_required
def add_user_info():
create_user_info = g.current_user
new_obj = BllUser().execute(f"select * from rms_user where user_code={request.values.get('user_code')} and user_code is not null").fetchone()
if new_obj:
return jsonify(Utils.false_return(msg="工号不能重复"))
try:
obj = EntityUser(
real_name=request.values.get("real_name"),
@ -88,9 +91,9 @@ def add_user_info():
create_user_name=create_user_info.real_name,
is_enabled=request.values.get("is_enabled")
)
setattr(obj, "password", Utils.MD5('123456'))
BllUser().insert(obj)
# BllUser().update()
return jsonify(Utils.true_return(msg="添加成功"))
return jsonify(Utils.true_return(msg=f"添加成功!"))
except Exception as error:
return jsonify(Utils.except_return(msg=error))
@ -115,13 +118,15 @@ def update_user_info():
if not obj:
return jsonify(Utils.false_return(msg="用户id有误"))
else:
new_obj = BllUser().findEntity(
and_(
EntityUser.user_code == obj.user_code,
EntityUser.user_code.isnot(None)
)
)
if obj.user_id != new_obj.user_id:
# new_obj = BllUser().findEntity(
# and_(
# EntityUser.user_code == obj.user_code,
# EntityUser.user_code.isnot(None)
# )
# )
new_obj = BllUser().execute(f"select * from rms_user where user_code={request.values.get('user_code')} and user_code is not null").fetchone()
if new_obj and obj.user_id == new_obj.user_id:
return jsonify(Utils.false_return(msg="工号不能重复"))
finds_list = dir(EntityUser)
for i in finds_list:

@ -53,7 +53,7 @@ class BllMedicament(Repository):
where_base = f" where {where_base} "
sql_all = f"""
select
`name`, english_name, cas_number, speci, net_weight_unit, purity,
`name`, english_name, cas_number, speci, net_weight_unit, purity, manufacturer,
sum(CASE WHEN `status`=1 THEN 1 ELSE 0 END) surplus_number
from rms_medicament {where_base} GROUP BY `name`, speci, purity order by put_in_date desc
"""
@ -358,7 +358,9 @@ class BllMedicament(Repository):
seach_w = f"%{search_word}%"
if filter_base:
filter_base += " and "
filter_base += f" (`name` like '{seach_w}' or english_name like '{seach_w}' or manufacturer like '{seach_w}') "
bar_code, new_code = Utils.get_bar_code_reverse(search_word)
filter_base += f" `name` like '{seach_w}' or english_name like '{seach_w}' or manufacturer like '{seach_w}' "
filter_base += f" or bar_code='{bar_code}' or bar_code='{new_code}' "
# 厂商搜索
if manufacturer:
manufacturer = f"%{manufacturer}%"
@ -374,7 +376,7 @@ class BllMedicament(Repository):
if func_type:
if filter_base:
filter_base += " and "
filter_base += f" func_type='{func_type}'"
filter_base += f" func_type={func_type}"
if filter_base:
filter_base = "where " + filter_base

@ -91,6 +91,19 @@ class BllModuleRelation(Repository):
return data_dict
def get_user_manage_auth(self, user_info):
sql_all = f"""
select module_code from (
select module_id, object_id from rms_module_relation where module_type=2 and (object_id='{user_info.user_id}' or object_id='{user_info.role_id}')
)as a LEFT JOIN (
select module_id, module_code from rms_module
)as b on a.module_id = b.module_id
"""
data = self.execute(sql_all).fetchall()
data_list = [i.module_code for i in data]
return data_list
def get_user_module_list(self, user_info):
sql_all = f"""
select a.module_id, a.module_name, a.module_type, a.module_code, a.sort_index,

@ -19,40 +19,10 @@ class BllWarning(Repository):
#获取预警列表
def getWarningList(self, pageParam=None,key_word=None, object_type=None, start_time=None, end_time=None):
# sql_all = """
# select * from rms_warning %s ORDER BY warning_date DESC
# """
# filter_base = ""
# if key_word:
# key_word = f"'%{key_word}%'"
# filter_base += f" where object_name like {key_word} or warning_user_name like {key_word} or warning_content like {key_word}"
# if object_type:
# if filter_base:
# filter_base += " and "
# filter_base += f" object_type={object_type} "
# if start_time and end_time:
# if filter_base:
# filter_base += " and "
# filter_base += f" warning_date >={start_time} and warning_date <= {end_time} "
# sql_all = sql_all % filter_base
# total_count = 0
# if not pageParam:
# sql_all += " limit 5"
# else:
# try:
# total_count = len(self.execute(sql_all).fetchall())
# except Exception:
# total_count = 0
# pageParam.totalRecords = total_count
# sql_all = Utils.sql_paging_assemble(sql_all=sql_all, page_param=pageParam)
# return self.execute(sql_all).fetchall()
sql_all = """
select * from rms_warning %s ORDER BY warning_date DESC
"""
filter_base = ""
if key_word:
key_word = f"'%{key_word}%'"
filter_base += f" where (object_name like {key_word} or warning_user_name like {key_word} or warning_content like {key_word})"
filter_base += f" (object_name like {key_word} or warning_user_name like {key_word} or warning_content like {key_word}) "
if object_type:
if filter_base:
filter_base += " and "
@ -60,12 +30,16 @@ class BllWarning(Repository):
if start_time and end_time:
if filter_base:
filter_base += " and "
filter_base += f" warning_date >={start_time} and warning_date <= {end_time} "
sql_all = sql_all % filter_base
total_count = 0
filter_base += f" warning_date >='{start_time}' and warning_date <= '{end_time}' "
if filter_base:
filter_base = f" where {filter_base}"
sql_all = f"""
select * from rms_warning {filter_base} ORDER BY warning_date DESC
"""
if not pageParam:
sql_all += " limit 5"
sql_all += " limit 5 "
else:
# sql_all += " ORDER BY warning_date DESC "
try:
total_count = len(self.execute(sql_all).fetchall())
except Exception:

Loading…
Cancel
Save