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

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

@ -34,7 +34,7 @@ class Utils(object):
else: else:
new_code = bar_code new_code = bar_code
return bar_code, new_code return bar_code, new_code
def getDrugUnitCode(num): def getDrugUnitCode(num):
return f"{Utils.get_file_name_datetime()[:8]}{(3-len(str(num+1)))* '0' + str(num+1)}" return f"{Utils.get_file_name_datetime()[:8]}{(3-len(str(num+1)))* '0' + str(num+1)}"
@ -47,7 +47,7 @@ class Utils(object):
def get_str_datetime(): def get_str_datetime():
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
def get_file_name_datetime(): def get_file_name_datetime():
return datetime.datetime.now().strftime("%Y%m%d%H%M%S") return datetime.datetime.now().strftime("%Y%m%d%H%M%S")
@ -58,7 +58,7 @@ class Utils(object):
def classify(num, all_num, fl=2): def classify(num, all_num, fl=2):
return str(round(float(round(float(num) / all_num, fl)) * 100)) + "%" return str(round(float(round(float(num) / all_num, fl)) * 100)) + "%"
# return str(round(float(round(math.ceil(num) / all_num, fl)) * 100)) + "%" # return str(round(float(round(math.ceil(num) / all_num, fl)) * 100)) + "%"
def model_to_dict(cls): def model_to_dict(cls):
return {c.name: getattr(cls, c.name, None) for c in cls.__table__.columns} return {c.name: getattr(cls, c.name, None) for c in cls.__table__.columns}
@ -82,7 +82,7 @@ class Utils(object):
# 根据自定义字段及数据顺序进行返回 # 根据自定义字段及数据顺序进行返回
def mysqlfinds_list(data, finds): def mysqlfinds_list(data, finds):
return [dict(zip(finds, i)) for i in data] return [dict(zip(finds, i)) for i in data]
# sqlalchemy 原生sql转换实体列表 # sqlalchemy 原生sql转换实体列表
def msyql_table_model(data_list): def msyql_table_model(data_list):
return[dict(i._mapping) for i in data_list] return[dict(i._mapping) for i in data_list]
@ -90,7 +90,7 @@ class Utils(object):
# return [dict(zip(result.keys(), [(x if x is not None else '') for x in result.values()])) for result in data_list] # return [dict(zip(result.keys(), [(x if x is not None else '') for x in result.values()])) for result in data_list]
# except: # except:
# return [dict(zip(i.keys(), i)) for i in data_list] # return [dict(zip(i.keys(), i)) for i in data_list]
# @classmethod # @classmethod
def to_dict(cls): def to_dict(cls):
return {c.name: getattr(cls, c.name, None) for c in cls.__table__.columns} return {c.name: getattr(cls, c.name, None) for c in cls.__table__.columns}
@ -167,7 +167,7 @@ class Utils(object):
return round(setTem + diffValue/coeValue, 1) return round(setTem + diffValue/coeValue, 1)
else: else:
return round(setTem - diffValue/coeValue, 1) return round(setTem - diffValue/coeValue, 1)
# # 获取最近24小时的值 # # 获取最近24小时的值
# def get_24_hours(self): # def get_24_hours(self):
# # 获取当前的小时值 # # 获取当前的小时值
@ -257,12 +257,12 @@ class Utils(object):
# data_temp.append('0.0') # data_temp.append('0.0')
# # 返回字段 # # 返回字段
# series_list = [{ # series_list = [{
# "name": client_obj.client_name, # "name": client_obj.client_name,
# "type": "line", # "type": "line",
# "data": data_temp, # "data": data_temp,
# "markPoint":{ # "markPoint":{
# "data": [ # "data": [
# {"type": "max", "name": "最大值"}, # {"type": "max", "name": "最大值"},
# {"type": "min", "name": "最小值"} # {"type": "min", "name": "最小值"}
# ] # ]
# }, # },
@ -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]
@ -369,4 +380,4 @@ class CabinetStatus(object):
AbnormalLightStatus = None # 异常灯是否亮 AbnormalLightStatus = None # 异常灯是否亮
class DooropenUser(): class DooropenUser():
user_id ='' user_id =''

@ -92,7 +92,7 @@ def drug_collect():
# print(k,v) # print(k,v)
# 试剂领用--事务逻辑处理 # 试剂领用--事务逻辑处理
BllMedicament().drugUse( BllMedicament().drugUse(
drug_entity, drug_entity,
BllClient().findEntity(EntityClient.client_id==client_id), BllClient().findEntity(EntityClient.client_id==client_id),
user_info, user_info,
notes =notes notes =notes
@ -116,8 +116,8 @@ def drug_return():
remain = request.values.get("remain") remain = request.values.get("remain")
# 默认用户id后续从token 中获取 # 默认用户id后续从token 中获取
# user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1' # user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1'
# 根据条码查询试剂信息 # 根据条码查询试剂信息
drug_info = BllMedicament().findEntity(EntityMedicament.bar_code==bar_code) drug_info = BllMedicament().findEntity(EntityMedicament.bar_code==bar_code)
if not drug_info: if not drug_info:
@ -220,7 +220,7 @@ def get_drug_info():
return jsonify(Utils.true_return(data=data[0])) return jsonify(Utils.true_return(data=data[0]))
else: else:
return jsonify(Utils.false_return(msg="条码有误")) return jsonify(Utils.false_return(msg="条码有误"))
@ -237,7 +237,7 @@ def get_drug_manage():
page_size = int(request.values.get("page_size", 10)) page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
data_list = BllMedicament().get_drug_list( data_list = BllMedicament().get_drug_list(
seach_word=seach_word, seach_word=seach_word,
b_code=b_code, b_code=b_code,
client_id=client_id, func_type=func_type, page_param=page_param client_id=client_id, func_type=func_type, page_param=page_param
) )
@ -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有误"))
@ -591,4 +593,4 @@ def print_select_drug_code():
obj = CreateBarcode() obj = CreateBarcode()
obj.create_drug_lobel_code(**new_dict) obj.create_drug_lobel_code(**new_dict)
return jsonify(Utils.true_return(msg="打印完成")) return jsonify(Utils.true_return(msg="打印完成"))

@ -32,10 +32,10 @@ class BllMedicament(Repository):
def get_register_list(self, user, page_param): def get_register_list(self, user, page_param):
# sql_all = f""" # sql_all = f"""
# select * from rms_user_apply # select * from rms_user_apply
# where # where
# user_id='{user.user_id}' and # user_id='{user.user_id}' and
# is_solve=1 and # is_solve=1 and
# solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour) # solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
# """ # """
@ -79,8 +79,8 @@ class BllMedicament(Repository):
# 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 # 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} # from rms_medicament where `name` like '%{drug_name}%' and status=1 and func_type={func_type}
# GROUP BY client_id, flow_position_code # 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
@ -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
# 药剂登记 # 药剂登记
@ -489,13 +479,13 @@ class BllMedicament(Repository):
filter_base1 += f"where place='{client_place}'" filter_base1 += f"where place='{client_place}'"
# sql_all =f""" # sql_all =f"""
# select DISTINCT # select DISTINCT
# `name`, speci, cas_number,net_weight_unit, purity, # `name`, speci, cas_number,net_weight_unit, 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
# 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 order by put_in_date desc
# """ # """
sql_all = f""" sql_all = f"""
@ -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