|
|
|
@ -10,6 +10,9 @@ import json
|
|
|
|
|
from flask import Blueprint, request, jsonify, g
|
|
|
|
|
from sqlalchemy import and_, or_
|
|
|
|
|
from db_logic.medicament_shengou import BllMedicamntShenGou
|
|
|
|
|
from db_logic.medicament_template import BllMedicamentTemplate
|
|
|
|
|
from db_logic.client import BllClient
|
|
|
|
|
from models.medicament_models import EntityMedicamentTemplate
|
|
|
|
|
from models.medicament_models import EntityMedicamntShenGou
|
|
|
|
|
from Common.report_shen_gou import ReportData
|
|
|
|
|
from db_logic.user import BllUser
|
|
|
|
@ -35,6 +38,7 @@ def get_shengou_list():
|
|
|
|
|
data_list = []
|
|
|
|
|
for i in data:
|
|
|
|
|
i_dict = dict(i._mapping)
|
|
|
|
|
# i_dict = dict(zip(i.keys(), [(x if x is not None else '') for x in i.values()]))
|
|
|
|
|
i_dict['user_name'] = user_dict.get(i_dict["user_id"])
|
|
|
|
|
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"], '')
|
|
|
|
@ -90,13 +94,20 @@ def update_shengou():
|
|
|
|
|
@token_auth.login_required
|
|
|
|
|
def solve_shengou():
|
|
|
|
|
shengou_id =request.values.get("id")
|
|
|
|
|
func_type = request.values.get("func_type")
|
|
|
|
|
user_id = g.current_user.user_id
|
|
|
|
|
obj = BllMedicamntShenGou().findEntity(EntityMedicamntShenGou.id == shengou_id)
|
|
|
|
|
if obj.is_solve == 1:
|
|
|
|
|
return jsonify(Utils.false_return(msg="已受理,无需重复受理"))
|
|
|
|
|
if str(request.values.get('result')) == "0":
|
|
|
|
|
if not obj.solve_user_id:
|
|
|
|
|
obj.solve_user_id = user_id
|
|
|
|
|
else:
|
|
|
|
|
if user_id == obj.solve_user_id:
|
|
|
|
|
return jsonify(Utils.false_return(msg="不能位同一人审批"))
|
|
|
|
|
obj.solve_user_id_pt=user_id
|
|
|
|
|
obj.is_solve = 2
|
|
|
|
|
obj.information = request.values.get("information")
|
|
|
|
|
obj.is_solve = 2
|
|
|
|
|
else:
|
|
|
|
|
if not obj.solve_user_id:
|
|
|
|
|
obj.solve_user_id = user_id
|
|
|
|
@ -105,6 +116,56 @@ def solve_shengou():
|
|
|
|
|
return jsonify(Utils.false_return(msg="不能位同一人审批"))
|
|
|
|
|
obj.solve_user_id_pt=user_id
|
|
|
|
|
obj.is_solve = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tmp_name=''
|
|
|
|
|
data = BllClient().get_all_client_list(func_type=func_type)
|
|
|
|
|
data_list = Utils.msyql_table_model(data)
|
|
|
|
|
tmp_content = obj.use_content
|
|
|
|
|
user = BllUser().findEntity(obj.user_id)
|
|
|
|
|
client = data_list[0]
|
|
|
|
|
sql_all = """
|
|
|
|
|
select bar_code_count, start_bar_code from rms_medicament_template where start_bar_code=(select max(start_bar_code) max_start from rms_medicament_template)
|
|
|
|
|
"""
|
|
|
|
|
# 获取最大的条形码和条形码数量
|
|
|
|
|
tmp_obj = BllMedicamentTemplate().execute(sql_all).fetchone()
|
|
|
|
|
if tmp_obj:
|
|
|
|
|
max_barcode = int(tmp_obj.start_bar_code) + int(tmp_obj.bar_code_count)
|
|
|
|
|
else:
|
|
|
|
|
max_barcode = 100001
|
|
|
|
|
start_bar_code = max_barcode
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if not tmp_content or tmp_content == 'null':
|
|
|
|
|
return jsonify(Utils.false_return(msg="模板内容有误"))
|
|
|
|
|
if not tmp_name:
|
|
|
|
|
tmp_name = f'入库模板_{Utils.getFileName()}'
|
|
|
|
|
if isinstance(tmp_content, str):
|
|
|
|
|
# tmp_content = eval(tmp_content)
|
|
|
|
|
tmp_content = json.loads(tmp_content)
|
|
|
|
|
bar_code_count = 0
|
|
|
|
|
for i in tmp_content:
|
|
|
|
|
bar_code_count += int(i['export_count'])
|
|
|
|
|
|
|
|
|
|
obj1 = EntityMedicamentTemplate(
|
|
|
|
|
customer_id='1002437b-debf-46d6-b186-3e16bcf0cc0f',
|
|
|
|
|
client_id=client["client_id"],
|
|
|
|
|
client_name=client["client_name"],
|
|
|
|
|
template_name=tmp_name,
|
|
|
|
|
func_type=func_type,
|
|
|
|
|
template_content=json.dumps(tmp_content),
|
|
|
|
|
is_wait_export=1,
|
|
|
|
|
start_bar_code=start_bar_code,
|
|
|
|
|
bar_code_count=bar_code_count,
|
|
|
|
|
create_date=Utils.get_str_datetime(),
|
|
|
|
|
create_user_id=user.user_id,
|
|
|
|
|
create_user_name=user.real_name,
|
|
|
|
|
is_add=1
|
|
|
|
|
)
|
|
|
|
|
BllMedicamentTemplate().insert(obj1)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
obj.solve_date = Utils.get_str_datetime()
|
|
|
|
|
BllMedicamntShenGou().update(obj)
|
|
|
|
|
return jsonify(Utils.true_return())
|
|
|
|
|