批量提交使用说明

duizhaopin
tangxuan 2 years ago
parent 0e9ffb6db5
commit 64f50d8fff

@ -372,26 +372,36 @@ def get_dangerous_list():
# @token_auth.login_required
def save_drug_img_info():
# 药剂类别
variety_id = request.values.get("variety_id")
medicament_id = request.values.get("medicament_id")
file_base64 = request.files.get("file")
# variety_id = request.values.get("variety_id")
# medicament_id = request.values.get("medicament_id")
if request.values.get("selected"):
medicament_list = json.loads(request.values.get("selected"))
else:
medicament_list = [{
"variety_id": request.values.get("variety_id"),
"medicament_id": request.values.get("medicament_id"),
}]
# try:
gaopaiyi_obj = GaoPaiYi()
img_path = f"{Utils.UUID()}.jpg"
file_base64.save(os.path.join(gaopaiyi_obj.path, img_path))
# 根据条码查询试剂信息
drug_info = BllMedicament().findEntity(
EntityMedicament.medicament_id == medicament_id)
if not drug_info:
return jsonify(Utils.false_return(msg="试剂信息有误"))
obj = EntityMedicamentRelationImage(
name=drug_info.name,
variety_id=variety_id,
medicament_id=medicament_id,
pic_url=img_path,
create_date=Utils.get_str_datetime(),
)
BllMedicamentRelationImage().insert(obj)
for medicament in medicament_list:
variety_id = medicament.get("variety_id")
medicament_id = medicament.get("medicament_id")
# 根据条码查询试剂信息
drug_info = BllMedicament().findEntity(
EntityMedicament.medicament_id == medicament_id)
if not drug_info:
return jsonify(Utils.false_return(msg="试剂信息有误"))
obj = EntityMedicamentRelationImage(
name=drug_info.name,
variety_id=variety_id,
medicament_id=medicament_id,
pic_url=img_path,
create_date=Utils.get_str_datetime(),
)
BllMedicamentRelationImage().insert(obj)
return jsonify(Utils.true_return(msg="上传成功"))
@ -405,24 +415,33 @@ def get_drug_img(img_path):
@token_auth.login_required
def use_gaopaiyi():
# 药剂类别
variety_id = request.values.get("variety_id")
medicament_id = request.values.get("medicament_id")
# variety_id = request.values.get("variety_id")
# medicament_id = request.values.get("medicament_id")
if request.values.get("selected"):
medicament_list = json.loads(request.values.get("selected"))
else:
medicament_list = [{
"variety_id": request.values.get("variety_id"),
"medicament_id": request.values.get("medicament_id"),
}]
pic_data = GaoPaiYi().getPic()
if pic_data['code'] == 0:
# 根据条码查询试剂信息
drug_info = BllMedicament().findEntity(
EntityMedicament.medicament_id == medicament_id)
obj = EntityMedicamentRelationImage(
name=drug_info.name,
variety_id=variety_id,
medicament_id=medicament_id,
pic_url=pic_data['path'],
create_date=Utils.get_str_datetime(),
)
BllMedicamentRelationImage().insert(obj)
for medicament in medicament_list:
variety_id = medicament.get("variety_id")
medicament_id = medicament.get("medicament_id")
# 根据条码查询试剂信息
drug_info = BllMedicament().findEntity(
EntityMedicament.medicament_id == medicament_id)
obj = EntityMedicamentRelationImage(
name=drug_info.name,
variety_id=variety_id,
medicament_id=medicament_id,
pic_url=pic_data['path'],
create_date=Utils.get_str_datetime(),
)
BllMedicamentRelationImage().insert(obj)
data = Utils.true_return(msg="高拍仪拍照成功")
else:
data = Utils.false_return(msg=pic_data['msg'])

Loading…
Cancel
Save