diff --git a/apps/client/views.py b/apps/client/views.py index a7400c7..7c6ca84 100644 --- a/apps/client/views.py +++ b/apps/client/views.py @@ -5,9 +5,18 @@ ''' from flask import Blueprint, jsonify, request from Common.Utils import Utils, PageParam -from db_logic.client import BllClient + from Common.auth import token_auth +from db_logic.client import BllClient +from db_logic.medicament_record import BllMedicamentRecord +from db_logic.medicament_template import BllMedicamentTemplate +from db_logic.meidcament_variety import BllMedicamentVariety +from db_logic.humiture_record import BllHumitureRecord +from db_logic.medicament import BllMedicament + from models.client_models import EntityClient +from models.medicament_models import EntityMedicament, EntityMedicamentRecord, EntityMedicamentTemplate, EntityMedicamentVariety +from models.humiture_models import EntityHumitureRecord client_router = Blueprint("client", __name__) @@ -23,7 +32,7 @@ def get_client_list(): # 查看列表 @client_router.route("/get_list", methods=["GET","POST"]) -@token_auth.login_required +# @token_auth.login_required def getclient_list(): seach_word = request.values.get("seach_word") page = request.values.get("page", 1) @@ -83,3 +92,53 @@ def update_status(): return jsonify(Utils.true_return(msg="修改成功")) else: return jsonify(Utils.false_return("柜体不存在")) + +# 删除柜体 +@client_router.route("/del", methods=["GET", "POST"]) +# @token_auth.login_required +def client_del(): + client_id = request.values.get("client_id") + drug_obj = BllMedicament().findEntity(EntityMedicament.client_id == client_id) + if drug_obj: + return jsonify(Utils.false_return(msg="请先删除柜体内试剂数据")) + else: + BllClient().delete(EntityClient.client_id==client_id) + BllMedicamentRecord().delete(EntityMedicamentRecord.client_id == client_id) + BllMedicamentTemplate().delete(EntityMedicamentTemplate.client_id == client_id) + BllHumitureRecord().delete(EntityHumitureRecord.client_id == client_id) + + return jsonify(Utils.true_return(msg="删除成功")) + + +# 清空所有需删除表数据 +# rms_user_medicament, rms_medicament_variety, +# rms_medicament_template,rms_medicament_record, +# rms_medicament_extend,rms_medicament, rms_humiture_record +# 清空指定柜体需删除 +# rms_medicament_template,rms_medicament_record,rms_medicament, rms_humiture_record + +@client_router.route("/client_empty", methods=["GET", "POST"]) +def client_empty(): + client_id = request.values.get("client_id") + if client_id: + BllMedicament().delete(EntityMedicament.client_id == client_id) + BllMedicamentRecord().delete(EntityMedicamentRecord.client_id == client_id) + BllMedicamentTemplate().delete(EntityMedicamentTemplate.client_id == client_id) + BllHumitureRecord().delete(EntityHumitureRecord.client_id == client_id) + else: + BllClient().empty_table_info() + return jsonify(Utils.true_return()) + + +# 分配抽屉权限展示 +@client_router.route("/get_drawer_power", methods=["GET", "POST"]) +def get_client_drawer_power(): + drawer_id = request.values.get("drawer_id") + + +# 分配抽屉权限 +@client_router.route("/set_drawer_power", methods=["GET", "POST"]) +def set_client_drawer_power(): + drawer_id = request.values.get("drawer_id") + + diff --git a/db_logic/client.py b/db_logic/client.py index 84f5d62..43f224e 100644 --- a/db_logic/client.py +++ b/db_logic/client.py @@ -30,7 +30,7 @@ class BllClient(Repository): def get_client_seach(self, seach_word, page_param): - filter_base = " " + filter_base = "" if seach_word: filter_base += f" client_name like %'{seach_word}'% " if filter_base: @@ -55,3 +55,20 @@ class BllClient(Repository): if customer_id: where_list.append(EntityClient.customer_id == customer_id) return self.findEntity(tuple(where_list)) + + def empty_table_info(self): + # 清空所有需删除表数据 + # rms_user_medicament, rms_medicament_variety, + # rms_medicament_template,rms_medicament_record, + # rms_medicament_extend,rms_medicament, rms_humiture_record + # 清空指定柜体需删除 + # rms_medicament_template,rms_medicament_record,rms_medicament, rms_humiture_record + table_list = [ + "rms_user_medicament", "rms_medicament_variety", + "rms_medicament_template","rms_medicament_record", + "rms_medicament_extend","rms_medicament", "rms_humiture_record" + ] + for i in table_list: + sql_all = f"truncate {i}" + self.execute(sql_all) + return True diff --git a/models/client_models.py b/models/client_models.py index a67078b..aaae50a 100644 --- a/models/client_models.py +++ b/models/client_models.py @@ -98,3 +98,16 @@ class EntityClientVersion(Base): create_user_id = Column(Integer, comment="创建用户ID") create_user_name = Column(String(50), comment="创建用户名") is_add = Column(Integer, comment="", default=1) + + +class EntityClientVersion(Base): + __tablename__ = "rms_client_cell" + __table_args__ = ( + { + "comment": "终端版本实体类" + } + ) + id = Column(String(50), primary_key=True, comment="ID", default=get_uuid) + cell_code = Column(String(50), comment="抽屉码") + client_id = Column(Integer, comment="终端id") + cell_speci = Column(String(50), comment="单元格")