1.试剂管理列表没有展示效期列

2.试剂管理里面有管理分类,入库时没有这个字段
3.称重设置空瓶时余量要变为0,并且设置空瓶时也要弹出用量,提示的用量保留两位小数,现在会出现很长一串数字的情况
4.普通危化品领用时会弹出一个用量事由框,这个弹出条件要判断一下,如果当前显示的就是这瓶试剂那就不用弹了,不然称重时也在弹会出现无法称重的情况
5.库存报表里面消耗数量一直为0,并且出现了好几个报表按照时间范围筛选无效的情况
duizhaopin
tangxuan 2 years ago
parent aa0881e47f
commit 5aebf0abdc

@ -304,6 +304,17 @@ class Utils(object):
} }
return data return data
@staticmethod
def reserve_decimal(num, n=2):
"""
保留n位小数
:param num: 浮点数
:param n: 小数位数
:return:
"""
deci = "0." + "0" * n
return Decimal(num).quantize(Decimal(deci))
if __name__ == '__main__': if __name__ == '__main__':
a = Utils.get_file_name_datetime()[:4] a = Utils.get_file_name_datetime()[:4]

@ -306,15 +306,17 @@ def drug_set_empty_bottle():
empty_str = request.values.get("empty_str") empty_str = request.values.get("empty_str")
obj = BllMedicament() obj = BllMedicament()
drug_obj = obj.findEntity(EntityMedicament.medicament_id == drug_id) drug_obj = obj.findEntity(EntityMedicament.medicament_id == drug_id)
remain_result = obj.calculate_use_drug(drug_obj, weight_remain=0)
if drug_obj: if drug_obj:
if drug_obj.status == 3: if drug_obj.status == 3:
return jsonify(Utils.false_return(msg="该试剂为空瓶,无需设置")) return jsonify(Utils.false_return(msg="该试剂为空瓶,无需设置"))
else: else:
drug_obj.status = 3 drug_obj.status = 3
drug_obj.remain = 0
if empty_str: if empty_str:
drug_obj.remark11=empty_str drug_obj.remark11=empty_str
obj.update(drug_obj) obj.update(drug_obj)
return jsonify(Utils.true_return()) return jsonify(Utils.true_return(data=remain_result))
else: else:
return jsonify(Utils.false_return(msg="试剂id有误")) return jsonify(Utils.false_return(msg="试剂id有误"))

@ -239,7 +239,7 @@ class BllMedicament(Repository):
filter_base += f" (`name` like '{seach_word}' or english_name like '{seach_word}') " filter_base += f" (`name` like '{seach_word}' or english_name like '{seach_word}') "
# 搜索bar_code # 搜索bar_code
if b_code: if b_code:
if len(b_code) > 10: if len(b_code) > 10 and str(func_type) == "1":
new_code = '' new_code = ''
for i in range(int(len(b_code) / 2)): for i in range(int(len(b_code) / 2)):
new_code = b_code[i*2:(i+1)*2] + new_code new_code = b_code[i*2:(i+1)*2] + new_code
@ -248,14 +248,14 @@ class BllMedicament(Repository):
new_code = f"%{new_code}%" new_code = f"%{new_code}%"
if filter_base: if filter_base:
filter_base += " and " filter_base += " and "
filter_base += f" bar_code like '{new_code}' " filter_base += f" bar_code like '{new_code}' or remark12 like '{new_code}' "
if filter_base: # if filter_base:
if len(seach_word) > 10: # if len(seach_word) > 10:
new_code = '' # new_code = ''
for i in range(int(len(seach_word) / 2)): # for i in range(int(len(seach_word) / 2)):
new_code = seach_word[i*2:(i+1)*2] + new_code # new_code = seach_word[i*2:(i+1)*2] + new_code
else: # else:
new_code = seach_word # new_code = seach_word
# TODO 确认下面这段和上面修改b_code代码作用 # TODO 确认下面这段和上面修改b_code代码作用
# new_code = f"%{new_code}%" # new_code = f"%{new_code}%"
# if filter_base: # if filter_base:
@ -269,7 +269,7 @@ class BllMedicament(Repository):
if filter_base: if filter_base:
filter_base = f" where {filter_base}" filter_base = f" where {filter_base}"
sql_all = f""" sql_all = f"""
select * from rms_medicament {filter_base} order by put_in_date desc select * from rms_medicament {filter_base} and status != 3 order by put_in_date desc
""" """
try: try:
count_number = len(self.execute(sql_all).fetchall()) count_number = len(self.execute(sql_all).fetchall())
@ -379,7 +379,6 @@ class BllMedicament(Repository):
drug = BllMedicament().findEntity(entityDrug.medicament_id) drug = BllMedicament().findEntity(entityDrug.medicament_id)
lastRemain = float(drug.remain) lastRemain = float(drug.remain)
remain_result = {"is_liquid": False, "use_volume": 0, "use_quality": 0}
if entityClient.client_id not in client_list: if entityClient.client_id not in client_list:
entityDrugRecord = EntityMedicamentRecord( entityDrugRecord = EntityMedicamentRecord(
@ -398,15 +397,6 @@ class BllMedicament(Repository):
create_user_name=entityUser.real_name, create_user_name=entityUser.real_name,
) )
# 液体用量 = 用量质量 / 密度
medicament_variety_obj = BllMedicamentVariety().findEntity(
EntityMedicamentVariety.variety_id == entityDrug.variety_id)
if medicament_variety_obj.net_weight_unit == 'ml' and medicament_variety_obj.density:
use_volume = (float(lastRemain) - float(
entityDrug.remain if entityDrug.remain else 0)) / medicament_variety_obj.density
entityDrugRecord.use_volume = use_volume
remain_result["is_liquid"] = True
remain_result["use_volume"] = use_volume
self.session.add(entityDrugRecord) self.session.add(entityDrugRecord)
entityVariety = BllMedicamentVariety().findEntity(entityDrug.variety_id) entityVariety = BllMedicamentVariety().findEntity(entityDrug.variety_id)
if(entityDrug.remain != 0): if(entityDrug.remain != 0):
@ -417,7 +407,7 @@ class BllMedicament(Repository):
self.session.merge(entityVariety) self.session.merge(entityVariety)
self.commitTrans() self.commitTrans()
remain_result["use_quality"] = float(lastRemain) - float(entityDrug.remain if entityDrug.remain else 0) remain_result = self.calculate_use_drug(drug, weight_remain=float(entityDrug.remain))
return remain_result return remain_result
# 药剂登记 # 药剂登记
@ -982,6 +972,26 @@ class BllMedicament(Repository):
self.session.merge(drug_entry) self.session.merge(drug_entry)
self.commitTrans() self.commitTrans()
@staticmethod
def calculate_use_drug(drug, weight_remain=0.0):
"""
计算用量
:return: {"is_liquid": 是否为液体, "use_volume": 液体用量, "use_quality": 固体用量, "net_weight_unit": 单位}
"""
medicament_variety_obj = BllMedicamentVariety().findEntity(
EntityMedicamentVariety.variety_id == drug.variety_id)
remain_result = {
"is_liquid": False,
"use_volume": 0,
"use_quality": float(drug.remain) - float(weight_remain),
"net_weight_unit": medicament_variety_obj.net_weight_unit
}
# 液体
if medicament_variety_obj.net_weight_unit == 'ml' and medicament_variety_obj.density:
use_volume = remain_result["use_quality"] / medicament_variety_obj.density
remain_result["is_liquid"] = True
remain_result["use_volume"] = Utils.reserve_decimal(use_volume, 2)
return remain_result

Loading…
Cancel
Save