试剂用量消耗统计

duizhaopin
tangxuan 2 years ago
parent 5aebf0abdc
commit dcc6897cb5

@ -164,6 +164,8 @@ def drun_input_info():
def stock_loss_info():
# 获取参数
seach_word = request.values.get('seach_word')
start_time = request.values.get("start_time")
end_time = request.values.get("end_time")
func_type = request.values.get("func_type")
@ -181,7 +183,10 @@ def stock_loss_info():
data = BllMedicamentRecord().durg_stock_loss(
seach_word=seach_word,
func_type=func_type,
page_param=page_param)
page_param=page_param,
start_time=start_time,
end_time=end_time,
)
if not download_tp:
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
else:
@ -209,6 +214,8 @@ def get_drug_use_expend():
page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size)
start_time = request.values.get("start_time")
end_time = request.values.get("end_time")
# 报表数据
download_tp = request.values.get("download_type", 0)
@ -218,7 +225,10 @@ def get_drug_use_expend():
data = BllMedicamentRecord().durg_useing_info(
seach_word=seach_word,
func_type=func_type,
page_param=page_param)
page_param=page_param,
start_time=start_time,
end_time=end_time,
)
if not download_tp:
return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
else:

@ -258,7 +258,7 @@ class BllMedicamentRecord(Repository):
return data_list, base_num
# 获取库存消耗数据
def durg_stock_loss(self, seach_word, func_type, page_param):
def durg_stock_loss(self, seach_word, func_type, page_param, start_time, end_time):
filter_base = ""
if seach_word:
seach_word = f"%{seach_word}%"
@ -267,6 +267,10 @@ class BllMedicamentRecord(Repository):
if filter_base:
filter_base += " and "
filter_base += f" func_type='{func_type}'"
if start_time and end_time:
if filter_base:
filter_base += " and "
filter_base += f" create_date >= '{start_time}' and create_date <= '{end_time}'"
if filter_base:
filter_base = f" where {filter_base}"
sql_all = f"""
@ -298,7 +302,7 @@ class BllMedicamentRecord(Repository):
return data_list
# 试剂用量消耗
def durg_useing_info(self, seach_word, func_type, page_param):
def durg_useing_info(self, seach_word, func_type, page_param, start_time, end_time):
# select medicament_id, FORMAT(sum(use_quantity),2) sum_use, sum(CASE WHEN record_type=2 THEN 1 ELSE 0 END) c_two from rms_medicament_record %s GROUP BY medicament_id
filter_base = ""
if seach_word:
@ -308,6 +312,11 @@ class BllMedicamentRecord(Repository):
if filter_base:
filter_base += " and "
filter_base += f" func_type='{func_type}'"
if start_time and end_time:
if filter_base:
filter_base += " and "
filter_base += f" create_date >= '{start_time}' and create_date <= '{end_time}'"
if filter_base:
filter_base = f" where {filter_base}"
sql_all = f"""
@ -316,7 +325,7 @@ class BllMedicamentRecord(Repository):
IFNULL(c_two,0) use_num, IFNULL(sum_use,0) use_level from (
select medicament_id, `name`, english_name, speci, cas_number, purity, net_weight_unit,put_in_date, `status`,func_type from rms_medicament
)as a LEFT JOIN(
select medicament_id, FORMAT(sum(use_quantity),2) sum_use, count(medicament_id) c_two from rms_medicament_record where record_type=2 GROUP BY medicament_id
select medicament_id, FORMAT(sum(use_quantity),2) sum_use, count(medicament_id) c_two from rms_medicament_record where record_type=3 GROUP BY medicament_id
) b on a.medicament_id=b.medicament_id {filter_base} GROUP BY `name`, purity, speci order by use_level desc
"""

Loading…
Cancel
Save