duizhaopin
13507605001 2 years ago
parent ba1a3d3c12
commit fd5c27d409

@ -101,8 +101,9 @@ def drug_return():
# 获取参数 # 获取参数
bar_code = request.values.get("bar_code") bar_code = request.values.get("bar_code")
func_type = request.values.get("func_type") func_type = request.values.get("func_type")
place = request.values.get("place") # place = request.values.get("place")
# user_id = request.values.get("user_id") # user_id = request.values.get("user_id")
remain = request.values.get("remain")
# 默认用户id后续从token 中获取 # 默认用户id后续从token 中获取
# user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1' # user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1'
@ -118,8 +119,9 @@ def drug_return():
else: else:
# 药剂归还,进入归还事务处理 # 药剂归还,进入归还事务处理
drug_info.status = DrugStatus.Normal drug_info.status = DrugStatus.Normal
if place: drug_info.remain = remain
drug_info.client_id = place # if place:
# drug_info.client_id = place
# user_info = BllUser().findEntity(EntityUser.user_id == user_id) # user_info = BllUser().findEntity(EntityUser.user_id == user_id)
user_info = g.current_user user_info = g.current_user

@ -85,9 +85,11 @@ def select_drug_info():
@token_auth.login_required @token_auth.login_required
def bind_tmp_input_db(): def bind_tmp_input_db():
tmp_content = request.values.get("tmplate_content") tmp_content = request.values.get("tmplate_content")
customer_id = request.values.get("customer_id", '1002437b-debf-46d6-b186-3e16bcf0cc0f') customer_id = request.values.get("customer_id")
if not customer_id:
customer_id = '1002437b-debf-46d6-b186-3e16bcf0cc0f'
func_type = request.values.get("func_type") func_type = request.values.get("func_type")
client_id = request.values.get("client_id") # client_id = request.values.get("client_id")
# client_id = '1c39cb24-07f8-11ed-abd4-f47b094925e1' # client_id = '1c39cb24-07f8-11ed-abd4-f47b094925e1'
bar_code = request.values.get("bar_code") bar_code = request.values.get("bar_code")
# user_id = request.values.get("user_id") # user_id = request.values.get("user_id")
@ -119,7 +121,7 @@ def bind_tmp_input_db():
"variety_id": drug_variety.variety_id, "variety_id": drug_variety.variety_id,
"bar_code": bar_code, "bar_code": bar_code,
"customer_id": customer_id, "customer_id": customer_id,
"client_id": client_id, # "client_id": client_id,
"inventory_warning_value":10, "inventory_warning_value":10,
"shelf_life_warning_value":10, "shelf_life_warning_value":10,
"use_days_warning_value":10, "use_days_warning_value":10,
@ -152,11 +154,12 @@ def bind_tmp_input_db():
# user_id = user_info.user_id # user_id = user_info.user_id
# user_id_pt = request.values.get("user_id_pt", '34306da6-0f11-11ed-ba01-009027e3906b') # user_id_pt = request.values.get("user_id_pt", '34306da6-0f11-11ed-ba01-009027e3906b')
# BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], auth_type=1) # BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], auth_type=1)
obj = CreateBarcode() obj = CreateBarcode()
obj.create_drug_lobel_code(**new_dict) obj.create_drug_lobel_code(**new_dict)
BllMedicament().drugPutIn( BllMedicament().drugPutIn(
drug_entity, drug_entity,
BllClient().findEntity(EntityClient.client_id==client_id), BllClient().findEntity(EntityClient.client_id==drug_entity.client_id),
user_info user_info
) )
return jsonify(Utils.true_return(msg="药剂入库成功")) return jsonify(Utils.true_return(msg="药剂入库成功"))

@ -23,6 +23,8 @@ monitor_router = Blueprint('monitor', __name__)
# @token_auth.login_required # @token_auth.login_required
def get_day_monitor(): def get_day_monitor():
client_id = request.values.get("client_id") client_id = request.values.get("client_id")
# TODO 添加房间筛选
client_place = request.values.get("client_place")
start_time = request.values.get("start_time") start_time = request.values.get("start_time")
end_time = request.values.get("end_time") end_time = request.values.get("end_time")
page = request.values.get("page", 1) page = request.values.get("page", 1)
@ -36,7 +38,8 @@ def get_day_monitor():
data_list = BllHumitureRecord().get_client_day_log( data_list = BllHumitureRecord().get_client_day_log(
client_id=client_id, start_time=start_time, client_id=client_id, start_time=start_time,
end_time=end_time, page_param=page_param end_time=end_time, page_param=page_param,
client_place=client_place
) )
if not download_tp: if not download_tp:
return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count": page_param.totalRecords})) return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count": page_param.totalRecords}))
@ -58,6 +61,8 @@ def get_day_monitor():
@token_auth.login_required @token_auth.login_required
def get_day_monitor_info(): def get_day_monitor_info():
client_id = request.values.get("client_id") client_id = request.values.get("client_id")
# TODO 添加房间筛选
client_place = request.values.get("client_place")
start_time = request.values.get("start_time") start_time = request.values.get("start_time")
end_time = request.values.get("end_time") end_time = request.values.get("end_time")
page = request.values.get("page", 1) page = request.values.get("page", 1)
@ -72,7 +77,8 @@ def get_day_monitor_info():
client_id=client_id, client_id=client_id,
start_time=start_time, start_time=start_time,
end_time=end_time, end_time=end_time,
page_param=page_param page_param=page_param,
client_place=client_place
) )
if not download_tp: if not download_tp:
return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count": page_param.totalRecords})) return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_count": page_param.totalRecords}))

@ -66,6 +66,9 @@ def get_stock_data_info():
func_type = request.values.get("func_type") func_type = request.values.get("func_type")
page = int(request.values.get('page', 1)) page = int(request.values.get('page', 1))
page_size = int(request.values.get('page_size', 15)) page_size = int(request.values.get('page_size', 15))
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_id = request.values.get("client_id")
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
# 导出报表功能 # 导出报表功能
@ -75,7 +78,10 @@ def get_stock_data_info():
data_list = BllMedicament().get_stock_all_info( data_list = BllMedicament().get_stock_all_info(
name=name, name=name,
func_type=func_type, func_type=func_type,
page_param=page_param) page_param=page_param,
client_place=client_place,
client_id=client_id
)
data_list = Utils.msyql_table_model(data_list) data_list = Utils.msyql_table_model(data_list)
if not download_tp: if not download_tp:
if data_list: if data_list:
@ -104,6 +110,7 @@ def drun_input_info():
manufacturer = request.values.get("manufacturer") manufacturer = request.values.get("manufacturer")
start_time = request.values.get("start_time") start_time = request.values.get("start_time")
end_time = request.values.get("end_time") end_time = request.values.get("end_time")
seach_user = request.values.get("seach_user")
func_type = request.values.get("func_type") func_type = request.values.get("func_type")
@ -129,7 +136,8 @@ def drun_input_info():
page_param=page_param, page_param=page_param,
customer_id=customer_id, customer_id=customer_id,
client_id=client_id, client_id=client_id,
client_speci=client_place client_speci=client_place,
seach_user=seach_user
) )
# 数据处理列表keyvalue格式 # 数据处理列表keyvalue格式
@ -319,6 +327,10 @@ def drug_log_type_info():
end_time = request.values.get("end_time") end_time = request.values.get("end_time")
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_id = request.values.get("client_id")
# 报表数据 # 报表数据
download_tp = request.values.get("download_type", 0) download_tp = request.values.get("download_type", 0)
if download_tp: if download_tp:
@ -330,7 +342,9 @@ def drug_log_type_info():
statue_type=statue_type, statue_type=statue_type,
name=name, name=name,
start_time=start_time, end_time=end_time, start_time=start_time, end_time=end_time,
page_param=page_param page_param=page_param,
client_place=client_place,
client_id=client_id
) )
data_list = Utils.msyql_table_model(data_list) data_list = Utils.msyql_table_model(data_list)
if not download_tp: if not download_tp:

@ -28,10 +28,11 @@ temporary_bp = Blueprint("temporary_auth", __name__)
@temporary_bp.route("/get_drug_group_list", methods=["POST"]) @temporary_bp.route("/get_drug_group_list", methods=["POST"])
def get_use_drug_list(): def get_use_drug_list():
client_id = request.values.get("client_id") client_id = request.values.get("client_id")
seach_word = request.values.get("seach_word")
page = request.values.get("page") page = request.values.get("page")
page_size = request.values.get("page_size") page_size = request.values.get("page_size")
page_param = PageParam(int(page), int(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 = BllMedicament().use_drug_info_list(client_id=client_id, seach_word=seach_word, page_param=page_param)
data_list = Utils.msyql_table_model(data_list=data) data_list = Utils.msyql_table_model(data_list=data)
return jsonify(Utils.true_return(data={"data_list":data_list, "total_count": page_param.totalRecords})) return jsonify(Utils.true_return(data={"data_list":data_list, "total_count": page_param.totalRecords}))
@ -158,10 +159,13 @@ def solve_apply():
# 展示待登记列表 # 展示待登记列表
@temporary_bp.route("/register_drug_list", methods=["GET", "POST"]) @temporary_bp.route("/register_drug_list", methods=["GET", "POST"])
@token_auth.login_required
def get_register_drug(): def get_register_drug():
data = BllMedicament().execute(f"select * from rms_medicament where status=4").fetchall() page = request.values.get("page")
data_list = Utils.msyql_table_model(data) page_size = request.values.get("page_size")
return jsonify(Utils.true_return(data=data_list)) page_param = PageParam(int(page), int(page_size))
data = BllMedicament().get_register_list(user=g.current_user, page_param=page_param)
return jsonify(Utils.true_return(data={"data_list":Utils.msyql_table_model(data), "total_count": page_param.totalRecords}))
# 登记接口 # 登记接口
@ -183,6 +187,9 @@ def set_register():
remain = request.values.get("remain") remain = request.values.get("remain")
# obj = BllMedicament().findEntity(EntityMedicament.medicament_id==drug_id) # obj = BllMedicament().findEntity(EntityMedicament.medicament_id==drug_id)
if obj: if obj:
# 开瓶日期
if not obj.remark13:
setattr(obj, "remark13", Utils.get_str_datetime())
setattr(obj, "remain", remain) setattr(obj, "remain", remain)
setattr(obj, "status", 2) setattr(obj, "status", 2)
BllMedicament().update(obj) BllMedicament().update(obj)

@ -52,7 +52,7 @@ class BllHumitureRecord(Repository):
# 获取每日记录,按时间,柜体分组展示 # 获取每日记录,按时间,柜体分组展示
def get_client_day_log(self, client_id, start_time, end_time, page_param): def get_client_day_log(self, client_id, start_time, end_time, page_param, client_place):
filter_base = "" filter_base = ""
if client_id: if client_id:
filter_base += f" client_id='{client_id}'" filter_base += f" client_id='{client_id}'"
@ -62,7 +62,10 @@ class BllHumitureRecord(Repository):
filter_base += f" record_date>= '{start_time}' and record_date<= '{end_time}' " filter_base += f" record_date>= '{start_time}' and record_date<= '{end_time}' "
if filter_base: if filter_base:
filter_base = f" where {filter_base} " filter_base = f" where {filter_base} "
#TODO 添加房间筛选
filter_base1 = ""
if client_place:
filter_base1 += f"where client_speci='{client_place}'"
sql_all = f""" sql_all = f"""
select a.client_id, a.client_name, a.day_date, a.avg_wd, a.avg_sd, a.avg_voc, b.place select a.client_id, a.client_name, a.day_date, a.avg_wd, a.avg_sd, a.avg_voc, b.place
from ( from (
@ -72,7 +75,9 @@ class BllHumitureRecord(Repository):
round(avg(humidity),2) avg_sd, round(avg(humidity),2) avg_sd,
round(avg(voc_content),2) avg_voc round(avg(voc_content),2) avg_voc
from rms_humiture_record {filter_base} GROUP BY client_id, DATE_FORMAT(record_date,'%Y-%m-%d') from rms_humiture_record {filter_base} GROUP BY client_id, DATE_FORMAT(record_date,'%Y-%m-%d')
) a LEFT JOIN rms_client as b on a.client_id=b.client_id ORDER BY day_date desc ) a LEFT JOIN (select * from rms_client {filter_base1}) as b on a.client_id=b.client_id
where b.place is not null
ORDER BY day_date desc
""" """
try: try:
count_number = len(self.execute(sql_all).fetchall()) count_number = len(self.execute(sql_all).fetchall())
@ -84,7 +89,7 @@ class BllHumitureRecord(Repository):
return self.execute(sql_all).fetchall() return self.execute(sql_all).fetchall()
# 获取每日记录详情 # 获取每日记录详情
def get_client_day_log_info(self, client_id, start_time, end_time, page_param): def get_client_day_log_info(self, client_id, start_time, end_time, page_param, client_place):
filter_base = "" filter_base = ""
if client_id: if client_id:
filter_base += f" client_id='{client_id}'" filter_base += f" client_id='{client_id}'"
@ -94,13 +99,33 @@ class BllHumitureRecord(Repository):
filter_base += f" record_date>= '{start_time}' and record_date<= '{end_time}' " filter_base += f" record_date>= '{start_time}' and record_date<= '{end_time}' "
if filter_base: if filter_base:
filter_base = f" where {filter_base}" filter_base = f" where {filter_base}"
#TODO 添加房间筛选
filter_base1 = ""
if client_place:
filter_base1 += f"where client_speci='{client_place}'"
# sql_all = f"""
# select
# DATE_FORMAT(record_date,'%H:%i:%s') day_date,
# round(temperature,2) as wd,
# round(humidity,2) as sd,
# round(voc_content,2) as voc
# from rms_humiture_record {filter_base} ORDER BY record_date
# """
sql_all = f""" sql_all = f"""
select a.*, b.place from (
select select
client_id,
DATE_FORMAT(record_date,'%H:%i:%s') day_date, DATE_FORMAT(record_date,'%H:%i:%s') day_date,
round(temperature,2) as wd, round(temperature,2) as wd,
round(humidity,2) as sd, round(humidity,2) as sd,
round(voc_content,2) as voc round(voc_content,2) as voc
from rms_humiture_record {filter_base} ORDER BY record_date from rms_humiture_record {filter_base}
) a LEFT JOIN (
select * from rms_client {filter_base1}
) b on a.client_id = b.client_id
where place is not null
ORDER BY a.day_date
""" """
try: try:
count_number = len(self.execute(sql_all).fetchall()) count_number = len(self.execute(sql_all).fetchall())

@ -26,18 +26,33 @@ class BllMedicament(Repository):
entity.remark30 = '0' entity.remark30 = '0'
return super().update(entity) return super().update(entity)
def get_register_list(self, user, page_param):
sql_all = f"""
select * from rms_medicament where status=4 and by_user_id='{user.user_id}'
"""
try:
total_count = self.execute(f"select count(*) num from rms_medicament where status=4 and by_user_id='{user.user_id}'").fetchone().num
except Exception:
total_count = 0
page_param.totalRecords = total_count
# 调用分页组装sql
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all).fetchall()
# 获取可入库层数据 # 获取可入库层数据
def get_drug_save_db_info(self, drug_name, func_type): def get_drug_save_db_info(self, drug_name, func_type):
sql_all = f""" sql_all = f"""
select name, IFNULL(num,0) number, c.client_id, cell_code, cell_speci from ( select name, IFNULL(num,0) number, c.client_name, c.client_id, cell_code, cell_speci from (
select cell_code, a.client_id, cell_speci, client_name from ( select cell_code, a.client_id, cell_speci, client_name from (
select * from rms_client_cell select * from rms_client_cell
) a LEFT JOIN( ) a LEFT JOIN(
select client_id, client_name from rms_client select client_id, client_name from rms_client
) b on a.client_id = b.client_id ) b on a.client_id = b.client_id
) c LEFT JOIN( ) c LEFT JOIN(
select NAME, client_id, flow_position_code, count(*) num from rms_medicament where `name` like '%{drug_name}%' and status=1, func_type={func_type} GROUP BY client_id, flow_position_code select name, client_id, flow_position_code, count(*) num
from rms_medicament where `name` like '%{drug_name}%' and status=1 and func_type={func_type}
GROUP BY client_id, flow_position_code
) d on c.client_id=d.client_id and c.cell_code=d.flow_position_code ) d on c.client_id=d.client_id and c.cell_code=d.flow_position_code
HAVING number < 40 HAVING number < 40
@ -48,9 +63,12 @@ class BllMedicament(Repository):
if i.client_id in data_dict.keys(): if i.client_id in data_dict.keys():
data_dict[i.client_id]["client_cell"].append(i.cell_speci) data_dict[i.client_id]["client_cell"].append(i.cell_speci)
else: else:
data_dict[i.client_id]["client_id"] = i.client_id client_dict = {
data_dict[i.client_id]["client_name"] = i.client_name "client_id": i.client_id,
data_dict[i.client_id]["client_cell"] = [i.cell_speci] "client_name": i.client_name,
"client_cell": [i.cell_speci]
}
data_dict[i.client_id] = client_dict
data_list = [] data_list = []
for k,v in data_dict.items(): for k,v in data_dict.items():
data_list.append(v) data_list.append(v)
@ -253,6 +271,7 @@ class BllMedicament(Repository):
# 创建事务 # 创建事务
self.beginTrans() self.beginTrans()
entityDrug.remark30 = '0' entityDrug.remark30 = '0'
entityDrug.client_code = entityClient.client_code
self.session.add(entityDrug) self.session.add(entityDrug)
if entityDrug.status == 1: if entityDrug.status == 1:
self.session.add(entityDrugRecord) self.session.add(entityDrugRecord)
@ -371,7 +390,7 @@ class BllMedicament(Repository):
# 获取库存信息总览 # 获取库存信息总览
def get_stock_all_info(self, page_param, func_type, name=None): def get_stock_all_info(self, page_param, func_type,client_id, name=None, client_place=None):
filter_base = "" filter_base = ""
if name: if name:
filter_base = f" `name` LIKE '%{name}%'" filter_base = f" `name` LIKE '%{name}%'"
@ -379,17 +398,43 @@ class BllMedicament(Repository):
if filter_base: if filter_base:
filter_base += " and " filter_base += " and "
filter_base += f" func_type='{func_type}' " filter_base += f" func_type='{func_type}' "
if client_id:
if filter_base:
filter_base += " and "
filter_base += f" client_id='{client_id}' "
if filter_base: if filter_base:
filter_base = f" where {filter_base}" filter_base = f" where {filter_base}"
sql_all =f""" #TODO 添加房间筛选
filter_base1 = ""
if client_place:
filter_base1 += f"where client_speci='{client_place}'"
# sql_all =f"""
# select DISTINCT
# `name`, speci, cas_number,net_weight_unit, purity,
# manufacturer, distributor, net_weight, net_weight_unit,
# client_id, put_in_user_name,category,expiration_date
# sum(CASE WHEN `status`=1 THEN 1 ELSE 0 END) count_number,
# sum(CASE WHEN `status`=1 THEN remain ELSE 0 END) sum_remain
# FROM rms_medicament {filter_base} GROUP BY `name`, speci, purity order by put_in_date desc
# """
sql_all = f"""
select a.*, b.client_name from (
select DISTINCT select DISTINCT
`name`, speci, cas_number,net_weight_unit, purity, `name`, speci, cas_number, purity,
manufacturer, distributor, net_weight, net_weight_unit, manufacturer, distributor, net_weight, net_weight_unit,
client_id, put_in_user_name,category,expiration_date client_id, put_in_user_name,category,expiration_date,put_in_date,
sum(CASE WHEN `status`=1 THEN 1 ELSE 0 END) count_number, sum(CASE WHEN `status`=1 THEN 1 ELSE 0 END) count_number,
sum(CASE WHEN `status`=1 THEN remain ELSE 0 END) sum_remain sum(CASE WHEN `status`=1 THEN remain ELSE 0 END) sum_remain
FROM rms_medicament {filter_base} GROUP BY `name`, speci, purity order by put_in_date desc FROM rms_medicament {filter_base} GROUP BY `name`, speci, purity
)a LEFT JOIN (
select * from rms_client {filter_base1}
) b on a.client_id=b.client_id
where b.client_name is not null
order by a.put_in_date desc
""" """
# 首次查询,判断长度,做分页使用 # 首次查询,判断长度,做分页使用
try: try:
@ -403,7 +448,7 @@ class BllMedicament(Repository):
return self.execute(sql_all).fetchall() return self.execute(sql_all).fetchall()
#获取所有药剂列表 #获取所有药剂列表
def getAllDrugList(self, search_word, manufacturer, start_time, end_time, func_type, page_param, customer_id=None, client_id=None, client_speci=None): def getAllDrugList(self, search_word, manufacturer, start_time, end_time, func_type, page_param, seach_user, customer_id=None, client_id=None, client_speci=None):
# (Name like :searchWord or BarCode like :searchWord or EnglishName like :searchWord) # (Name like :searchWord or BarCode like :searchWord or EnglishName like :searchWord)
filter_base = "" filter_base = ""
if customer_id: if customer_id:
@ -436,19 +481,22 @@ class BllMedicament(Repository):
if filter_base: if filter_base:
filter_base += " and " filter_base += " and "
filter_base += f" func_type={func_type}" filter_base += f" func_type={func_type}"
if seach_user:
if filter_base:
filter_base += " and "
filter_base += f" put_in_user_name like '%{seach_user}%'"
if filter_base: if filter_base:
filter_base = "where " + filter_base filter_base = "where " + filter_base
# select * from rms_medicament {filter_base} # select * from rms_medicament {filter_base}
#TODO 添加房间筛选 #TODO 添加房间筛选
filter_base1 = "" filter_base1 = ""
# if client_speci: if client_speci:
# filter_base1 += f"where client_speci='{client_speci}'" filter_base1 += f"where client_speci='{client_speci}'"
sql_all = f""" sql_all = f"""
select a.*,b.client_name from ( select a.*,b.client_name from (
select select
name, english_name,bar_code,manufacturer,speci,remain,purity,production_date,shelf_life,expiration_date,put_in_date,put_in_user_name, name, english_name,bar_code,manufacturer,speci,remain,purity,production_date,shelf_life,expiration_date,put_in_date,put_in_user_name,
status,by_user_name,client_id, count(*) count_number status,by_user_name,client_id
from rms_medicament {filter_base} from rms_medicament {filter_base}
) a LEFT JOIN( ) a LEFT JOIN(
select client_id,client_name from rms_client {filter_base1} select client_id,client_name from rms_client {filter_base1}
@ -474,13 +522,14 @@ class BllMedicament(Repository):
return self.execute(sql_all).fetchall() return self.execute(sql_all).fetchall()
# 入库、领用、归还记录 # 入库、领用、归还记录
def drug_show_type_info(self, record_type, start_time, end_time, put_in_user_name, name, func_type, statue_type, page_param): def drug_show_type_info(self, record_type, start_time, end_time, put_in_user_name, name, func_type, client_id, statue_type, page_param, client_place):
filter_base1 = f" WHERE record_type={record_type} " filter_base1 = f" WHERE record_type={record_type} "
if put_in_user_name: if put_in_user_name:
filter_base1 += f" and create_user_name like '%{put_in_user_name}%'" filter_base1 += f" and create_user_name like '%{put_in_user_name}%'"
if start_time and end_time: if start_time and end_time:
filter_base1 += f" and create_date >= '{start_time}' and create_date <= '{end_time}'" filter_base1 += f" and create_date >= '{start_time}' and create_date <= '{end_time}'"
if client_id:
filter_base1 += f" and client_id='{client_id}'"
filter_base2 = '' filter_base2 = ''
if name: if name:
name = f"%{name}%" name = f"%{name}%"
@ -497,6 +546,10 @@ class BllMedicament(Repository):
filter_base2 += f" func_type='{func_type}' " filter_base2 += f" func_type='{func_type}' "
if filter_base2: if filter_base2:
filter_base2 = f" where {filter_base2}" filter_base2 = f" where {filter_base2}"
#TODO 添加房间筛选
filter_base = ""
if client_place:
filter_base += f"where client_speci='{client_place}'"
sql_all = f""" sql_all = f"""
select select
`name`, english_name, bar_code, purity, `name`, english_name, bar_code, purity,
@ -511,8 +564,8 @@ class BllMedicament(Repository):
by_user_date, by_user_name, unit_code by_user_date, by_user_name, unit_code
FROM rms_medicament {filter_base2} FROM rms_medicament {filter_base2}
) as b on a.medicament_id=b.medicament_id ) as b on a.medicament_id=b.medicament_id
LEFT JOIN(select client_id,client_name from rms_client) c on a.client_id=c.client_id LEFT JOIN(select client_id,client_name from rms_client {filter_base}) c on a.client_id=c.client_id
where name is not null GROUP BY create_date desc where name is not null and client_name is not null ORDER BY create_date desc
""" """
try: try:
count_number = len(self.execute(sql_all).fetchall()) count_number = len(self.execute(sql_all).fetchall())
@ -558,20 +611,17 @@ class BllMedicament(Repository):
return self.execute(sql_all).fetchall() return self.execute(sql_all).fetchall()
# 可领用试剂列表 # 可领用试剂列表
def use_drug_info_list(self, client_id, page_param): def use_drug_info_list(self, client_id, seach_word, page_param):
filter_base = "" filter_base = ""
if client_id: if client_id:
filter_base += f"client_id='{client_id}'" filter_base += f"client_id='{client_id}'"
if seach_word:
if filter_base:
filter_base += " and "
name = f"%{seach_word}%"
filter_base += f" (`name` like '{name}' or english_name like '{name}') "
if filter_base: if filter_base:
filter_base = f" and {filter_base}" filter_base = f" and {filter_base}"
"""
select
`name`, speci, purity, count(*) drug_num, manufacturer, distributor
from
rms_medicament WHERE `status`=1 {filter_base}
GROUP BY
`name`, speci, purity, client_id
"""
sql_all = f""" sql_all = f"""
select a.*,b.client_name from ( select a.*,b.client_name from (
select select

@ -30,29 +30,28 @@ def picture_shoot(image_name='img.png', image_path=r'C:/local_project/imgs') ->
cv2.destroyAllWindows() cv2.destroyAllWindows()
# if __name__ == '__main__': # if __name__ == '__main__':
# picture_shoot() # picture_shoot()
import json # from db_logic.module import BllModule
data_list = [ from Common.Utils import Utils
{"id": 1, "use_content": json.dumps([{"name":"氨水","num":1,"client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","purity":"25~28%","speci":"500"}])}, data = BllModule().findList(EntityModule.module_type=='4')
{"id": 2, "use_content": json.dumps([{"name":"双氧水","num":1,"client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","purity":"25~28%","speci":"500"}])}, for i in data:
{"id": 4, "use_content": json.dumps([{"name":"硫酸水","num":1,"client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","purity":"25~28%","speci":"500"}])}, i.module_name = str(i.module_name).replace("耗材", "对照品")
]
drug_list = [] BllModule().update(i)
update_id = ''
client_id = '1c39cb24-07f8-11ed-abd4-f47b094925e1' # data = BllModule().execute("select * from rms_module where module_type=2 order by sort_index").fetchall()
drug_info = {"name": "双氧水"} # data_list = Utils.msyql_table_model(data)
for d in data_list: # inster_list = []
if update_id: # ind = 48
break # for i in range(len(data_list)):
use_content = json.loads(d["use_content"]) # d = data_list[i]
for j in range(len(use_content)): # del d['module_id']
# for j in use_content: # d['module_type'] = 4
j_info = use_content[j] # d['module_name'] = d['module_name'].replace("试剂", "对照品")
if j_info["client_id"] == client_id and j_info["name"] == drug_info["name"] and j_info["purity"] == "25~28%" and j_info["speci"] == "500": # d['module_code'] = d['module_code'].replace("Drug", "DZP")
if not j_info.get("use_num"): # d['sort_index'] = ind
j_info["use_num"] = 0 # d['module_weight'] = ind
if int(j_info["use_num"]) == int(j_info["num"]):
continue # inster_list.append(EntityModule(**d))
else: # ind += 1
j_info["use_num"] += 1 # print(11111)
update_id = d["id"] # BllModule().insert_many(inster_list)
print(use_content)

@ -5,6 +5,7 @@
''' '''
import sys import sys
sys.path.append(".") sys.path.append(".")
import os
from config.server import create_app from config.server import create_app
from Common.exception_base import APIException from Common.exception_base import APIException
from config.SystemConfig import SystemConfig from config.SystemConfig import SystemConfig

Loading…
Cancel
Save