parent
3e3e017666
commit
a46d412924
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
'''
|
||||
@Date: 2022/12/14 15:17:57
|
||||
'''
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
import json
|
||||
from flask import Blueprint, request, jsonify, g
|
||||
|
||||
from db_logic.user_temporary_auth import BllUserTemporaryAuth
|
||||
from db_logic.user_apply import BllUserApply
|
||||
from db_logic.medicament import BllMedicament
|
||||
from db_logic.client import BllClient
|
||||
from db_logic.user import BllUser
|
||||
from models.client_models import EntityClient
|
||||
from models.power_models import EntityUserApply, EntityUserTemporaryAuth
|
||||
from Common.Utils import Utils, PageParam
|
||||
from Common.auth import token_auth
|
||||
|
||||
temporary_bp = Blueprint("temporary_auth", __name__)
|
||||
|
||||
|
||||
|
||||
# 获取试剂分组列表
|
||||
@temporary_bp.route("/get_drug_group_list", methods=["POST"])
|
||||
def get_use_drug_list():
|
||||
client_id = request.values.get("client_id")
|
||||
page = request.values.get("page")
|
||||
page_size = request.values.get("page_size")
|
||||
page_param = PageParam(int(page), int(page_size))
|
||||
data = BllMedicament().use_drug_info_list(client_id=client_id, page_param=page_param)
|
||||
data_list = Utils.msyql_table_model(data_list=data)
|
||||
return jsonify(Utils.true_return(data={"data_list":data_list, "total_count": page_param.totalRecords}))
|
||||
|
||||
|
||||
# 创建申请记录
|
||||
@temporary_bp.route("/add", methods=["POST"])
|
||||
def user_apply_log():
|
||||
user_id = request.values.get("user_id")
|
||||
user_id_pt = request.values.get("user_id_pt")
|
||||
drug_name = request.values.get("drug_name")
|
||||
drug_num = request.values.get("drug_num")
|
||||
client_id = request.values.get("client_id")
|
||||
func_type = request.values.get("func_type")
|
||||
use_doc = request.values.get("use_doc")
|
||||
try:
|
||||
client_code = BllClient().findEntity(EntityClient.client_id==client_id).client_code
|
||||
except:
|
||||
client_code = ''
|
||||
obj = EntityUserApply(
|
||||
user_id = user_id,
|
||||
user_id_pt = user_id_pt,
|
||||
drug_name = drug_name,
|
||||
drug_num = drug_num,
|
||||
create_date = Utils.get_str_datetime(),
|
||||
is_solve = 0,
|
||||
client_id = client_id,
|
||||
func_type=func_type,
|
||||
client_code=client_code,
|
||||
use_doc=use_doc
|
||||
)
|
||||
BllUserApply().insert(obj)
|
||||
return jsonify(Utils.true_return())
|
||||
|
||||
# 展示
|
||||
@temporary_bp.route("/get_list", methods=["POST"])
|
||||
# @token_auth.login_required
|
||||
def get_info_list():
|
||||
client_id = request.values.get("client_id")
|
||||
func_type = request.values.get("func_type")
|
||||
page = request.values.get("page")
|
||||
page_size = request.values.get("page_size")
|
||||
page_param = PageParam(int(page), int(page_size))
|
||||
data = BllUserApply().get_list_info(client_id=client_id, func_type=func_type, page_param=page_param)
|
||||
user_list = BllUser().findList()
|
||||
user_dict = {}
|
||||
for i in user_list:
|
||||
user_dict[i.user_id] = i.real_name
|
||||
data_list = []
|
||||
for i in data:
|
||||
i_dict = dict(i._mapping)
|
||||
i_dict['user_name'] = user_dict.get(i_dict["user_id"])
|
||||
i_dict["user_name_pt"] = user_dict.get(i_dict["user_id_pt"])
|
||||
i_dict["solve_user_name"] = user_dict.get(i_dict["solve_user_id"], '')
|
||||
i_dict["solve_user_pt_name"] = user_dict.get(i_dict["solve_user_id_pt"], '')
|
||||
data_list.append(i_dict)
|
||||
return jsonify(Utils.true_return(data= {"data_list":data_list, "total_count": page_param.totalRecords}))
|
||||
|
||||
# 删除
|
||||
@temporary_bp.route("/del", methods=["POST"])
|
||||
@token_auth.login_required
|
||||
def del_user_apply():
|
||||
user_json = request.values.get("user_ids")
|
||||
user_id_list = user_json.split(",")
|
||||
for i in user_id_list:
|
||||
BllUserApply().delete(EntityUserApply.id==i)
|
||||
return jsonify(Utils.true_return())
|
||||
|
||||
# 处理消息
|
||||
@temporary_bp.route("/update_solve", methods=["POST"])
|
||||
@token_auth.login_required
|
||||
def solve_apply():
|
||||
apply_id =request.values.get("id")
|
||||
user_id = request.values.get("user_id")
|
||||
user_id_pt = request.values.get("user_id_pt")
|
||||
obj = BllUserApply().findEntity(EntityUserApply.id == apply_id)
|
||||
if obj.is_solve == 1:
|
||||
return jsonify(Utils.false_return(msg="已受理,无需重复受理"))
|
||||
obj.is_solve = 1
|
||||
obj.solve_date = Utils.get_str_datetime()
|
||||
obj.solve_user_id = user_id
|
||||
obj.solve_user_id_pt = user_id_pt
|
||||
BllUserTemporaryAuth().create_temporary_auth(user_ids=[obj.user_id, obj.user_pt], client_id=obj.client_id)
|
||||
BllUserApply().update(obj)
|
||||
return jsonify(Utils.true_return())
|
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
'''
|
||||
@Date:2022/08/12 15:12:42
|
||||
'''
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
from db_logic.db_base import Repository
|
||||
|
||||
from models.medicament_models import EntityMedicamentRelationImage
|
||||
|
||||
from Common.Utils import Utils
|
||||
|
||||
|
||||
#药剂品种业务逻辑类
|
||||
class BllMedicamentRelationImage(Repository):
|
||||
def __init__(self, entityType=EntityMedicamentRelationImage):
|
||||
super().__init__(entityType)
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
'''
|
||||
@Date: 2022/12/14 15:15:48
|
||||
'''
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
|
||||
from db_logic.db_base import Repository
|
||||
from models.power_models import EntityUserApply
|
||||
from Common.Utils import Utils
|
||||
|
||||
class BllUserApply(Repository):
|
||||
|
||||
def __init__(self, entityType=EntityUserApply):
|
||||
super().__init__(entityType)
|
||||
|
||||
def get_list_info(self, client_id, func_type, page_param):
|
||||
fileter_base = ""
|
||||
if client_id:
|
||||
fileter_base += f" client_id='{client_id}'"
|
||||
if func_type:
|
||||
if fileter_base:
|
||||
fileter_base += " and "
|
||||
fileter_base += f" func_type={func_type}"
|
||||
if fileter_base:
|
||||
fileter_base = f" where {fileter_base}"
|
||||
|
||||
sql_all = f"""
|
||||
select a.*, b.client_name from (
|
||||
select * from rms_user_apply {fileter_base}
|
||||
) a LEFT JOIN (
|
||||
select * from rms_client
|
||||
) b on a.client_id=b.client_id
|
||||
order by a.create_date desc
|
||||
"""
|
||||
try:
|
||||
count_number = self.execute(f"select count(*) num from rms_user_apply {fileter_base} order by create_date desc").fetchone().num
|
||||
except Exception:
|
||||
count_number = 0
|
||||
if page_param:
|
||||
page_param.totalRecords = count_number
|
||||
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
|
||||
return self.execute(sql_all).fetchall()
|
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
'''
|
||||
@Date: 2022/12/14 15:14:59
|
||||
'''
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
|
||||
import datetime
|
||||
from sqlalchemy import and_
|
||||
from Common.Utils import Utils
|
||||
from db_logic.db_base import Repository
|
||||
from models.power_models import EntityUserTemporaryAuth
|
||||
from db_logic.client import BllClient
|
||||
from models.client_models import EntityClient
|
||||
|
||||
class BllUserTemporaryAuth(Repository):
|
||||
|
||||
def __init__(self, entityType=EntityUserTemporaryAuth):
|
||||
super().__init__(entityType)
|
||||
|
||||
def create_temporary_auth(self, user_ids, client_id):
|
||||
try:
|
||||
client_code = BllClient().findEntity(EntityClient.client_id == client_id).client_code
|
||||
except:
|
||||
client_code = ''
|
||||
for user_id in user_ids:
|
||||
obj = self.findEntity(
|
||||
and_(
|
||||
self.entityType.user_id == user_id, client_id== client_id
|
||||
)
|
||||
)
|
||||
end_date = str(datetime.datetime.now() + datetime.timedelta(minutes=10))[:-7]
|
||||
if obj:
|
||||
obj.create_date = Utils.get_str_datetime()
|
||||
obj.end_date = end_date
|
||||
obj.client_id = client_id
|
||||
obj.client_code = client_code
|
||||
self.update(obj)
|
||||
else:
|
||||
obj = self.entityType()
|
||||
obj.user_id=user_id
|
||||
obj.create_date = Utils.get_str_datetime()
|
||||
obj.end_date = end_date
|
||||
obj.client_id = client_id
|
||||
obj.client_code = client_code
|
||||
self.insert(obj)
|
Loading…
Reference in new issue