柜体管理1

duizhaopin
apan_youxiang@163.com 2 years ago
parent c3f4c92f73
commit defa33efd2

@ -4,9 +4,10 @@
@Date:2022/07/29 09:03:39
'''
from flask import Blueprint, jsonify, request
from Common.Utils import Utils
from Common.Utils import Utils, PageParam
from db_logic.client import BllClient
from Common.auth import token_auth
from models.client_models import EntityClient
client_router = Blueprint("client", __name__)
@ -18,3 +19,67 @@ def get_client_list():
data = BllClient().get_all_client_list()
data_list = Utils.msyql_table_model(data)
return jsonify(Utils.true_return(data={"data_list": data_list}))
# 查看列表
@client_router.route("/get_list", methods=["GET","POST"])
# @token_auth.login_required
def getclient_list():
seach_word = request.values.get("seach_word")
page = request.values.get("page", 1)
page_size = request.values.get("page_size", 100)
page_param = PageParam(int(page), int(page_size))
data = BllClient().get_client_seach(
seach_word=seach_word, page_param=page_param
)
data_list = Utils.msyql_table_model(data)
return jsonify(Utils.true_return(data={"data_list": data_list, "total_count": page_param.totalRecords}))
# 新增and编辑
@client_router.route("/add_or_update", methods=["GET", "POST"])
# @token_auth.login_required
def client_add_update():
finds = [
"client_title", "client_code", "client_type", "place", "filter_production_date",
"filter_shelf_life_warning_value", "contact_people_name", "contact_phone", "description"
]
client_id = request.values.get("client_id")
obj = BllClient().findEntity(
EntityClient.client_code == request.values.get("client_code")
)
if client_id:
client_obj = BllClient().findEntity(
EntityClient.client_id==client_id
)
if obj:
if client_obj.client_id != obj.client_id:
return jsonify(Utils.false_return())
for i in finds:
setattr(client_obj, i, request.values.get(i))
BllClient().update(client_obj)
return jsonify(Utils.true_return(msg="修改成功"))
else:
if obj:
return jsonify(Utils.false_return(msg="柜体需要不能重复"))
client_obj = EntityClient()
for i in finds:
setattr(client_obj, i, request.values.get(i))
BllClient().insert(client_obj)
return jsonify(Utils.true_return(msg="添加成功"))
# 锁定或解锁柜体
@client_router.route("/update_status", methods=["GET", "POST"])
# @token_auth.login_required
def update_status():
status_type = request.values.get("status_type")
client_id = request.values.get("client_id")
obj = BllClient()
client_obj = obj.findEntity(EntityClient.client_id == client_id)
if client_obj:
client_obj.is_enabled=status_type
obj.update(client_obj)
return jsonify(Utils.true_return(msg="修改成功"))
else:
return jsonify(Utils.false_return("柜体不存在"))

@ -4,6 +4,7 @@
@Date:2022/07/19 16:34:34
'''
from flask import jsonify, request, Blueprint, g
from sqlalchemy import and_
from Common.auth import token_auth
from Common.Utils import PageParam, Utils
@ -115,6 +116,14 @@ 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:
return jsonify(Utils.false_return(msg="工号不能重复"))
obj.real_name = request.values.get("real_name")
obj.mobile = request.values.get("mobile")
obj.sex = request.values.get("sex")

@ -6,10 +6,12 @@ te:2022/07/18 16:32:26
'''
import sys
sys.path.append(".")
from Common.Utils import Utils
import os
print(os.getcwd())
from sqlalchemy import asc
from .db_base import Repository
from db_logic.db_base import Repository
from models.client_models import EntityClient
@ -26,6 +28,25 @@ class BllClient(Repository):
sql_all = """select * from rms_client order by client_code """
return self.execute(sql_all).fetchall()
def get_client_seach(self, seach_word, page_param):
filter_base = " "
if seach_word:
filter_base += f" client_name like %'{seach_word}'% "
if filter_base:
filter_base = f" where {filter_base} "
sql_all = f"""
select * from rms_client {filter_base} order by client_code
"""
try:
count_number = len(self.execute(sql_all).fetchall())
except Exception:
count_number = 0
page_param.totalRecords=count_number
page_sql = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(page_sql)
# 根据条件查询客户端信息
def get_filter_client(self, client_id, customer_id):
where_list = []

@ -30,19 +30,22 @@ class EntityClient(Base):
contact_people_name = Column(String(50), comment='联系人名称') # 联系人电话
contact_phone = Column(String(50), comment='联系人电话') # 联系人
total_run_time = Column(Integer, comment='总运行时长') # 总运行时长
temperature_control_swich = Column(Integer, comment='温控开关')
light_control_swich = Column(Integer, comment='照明灯控制开关')
fan_control_swich = Column(Integer, comment='风扇控制开关')
temperature_set_value = Column(Float, comment='温度设定值') # 温度设定控温值
temperature_max_value = Column(Float, comment='温度上限值') # 温度预警上限
temperature_min_value = Column(Float, comment='温度下限值') # 温度预警下限
humidity_max_value = Column(Float, comment='湿度上限值') # 湿度预警上限
humidity_min_value = Column(Float, comment='湿度下限值') # 湿度预警下限
temperature_control_swich = Column(Integer, comment='温控开关', default=0)
light_control_swich = Column(Integer, comment='照明灯控制开关', default=0)
fan_control_swich = Column(Integer, comment='风扇控制开关', default=0)
temperature_set_value = Column(
Float, comment='温度设定值', default=0.0) # 温度设定控温值
temperature_max_value = Column(
Float, comment='温度上限值', default=0.0) # 温度预警上限
temperature_min_value = Column(
Float, comment='温度下限值', default=0.0) # 温度预警下限
humidity_max_value = Column(Float, comment='湿度上限值', default=0.0) # 湿度预警上限
humidity_min_value = Column(Float, comment='湿度下限值', default=0.0) # 湿度预警下限
filter_production_date = Column(String(50), comment='药剂柜滤芯生产日期') # 滤芯生产日期
filter_shelf_life = Column(Integer, comment='药剂柜滤芯寿命') # 滤芯保质期
filter_shelf_life_warning_value = Column(
Integer, comment='药剂柜滤芯寿命到期前预警天数') # 滤芯保质期到期提前预警天数
is_enabled = Column(Integer, comment='有效标记') # 是否启用
is_enabled = Column(Integer, comment='有效标记', default=1) # 是否启用
sort_index = Column(Integer, comment='排序序号') # 排序序号
parent_id = Column(Integer, comment='父级Id') # 父级ID
description = Column(String(200), comment='备注') # 备注

Loading…
Cancel
Save