@ -15,7 +15,7 @@ from db_logic.meidcament_variety import BllMedicamentVariety
from db_logic . variety import BllVariety
from Common . Utils import Utils , DrugStatus , DrugRecordType
client_list = [ ' 72e70542-b70d-11e8-aea5-448a5bc6c411 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c412 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c413 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c414 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c415 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c416 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c417 ' ]
#药剂流程业务逻辑类
class BllMedicament ( Repository ) :
@ -28,6 +28,32 @@ class BllMedicament(Repository):
return super ( ) . update ( entity )
def get_register_list ( self , user , page_param ) :
# sql_all = f"""
# select * from rms_user_apply
# where
# user_id='{user.user_id}' and
# is_solve=1 and
# solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
# """
# data = self.execute(sql_all).fetchall()
# data_list = []
# for i in data:
# use_content = json.loads(i.use_content)
# for j_index in range(len(use_content)):
# j = use_content[j_index]
# if not j.get("use_num"):
# # j["stay_use_num"] = j.get("use_num")
# drugobj =BllMedicament().findEntity(and_(EntityMedicament.status==4,EntityMedicament.medicament_id == j.get("medicament_id")))
# print(drugobj,'889898989898989')
# if drugobj:
# data_list.append(j)
# #所有试剂
sql_all = f """
select * from rms_medicament where status = 4 and by_user_id = ' {user.user_id} '
"""
@ -63,7 +89,7 @@ class BllMedicament(Repository):
from (
select a . cell_code , a . client_id , a . cell_speci , IFNULL ( a . storage_quantity , 0 ) storage_quantity , count ( b . name ) num , IFNULL ( GROUP_CONCAT ( b . name ) , ' ' ) name_json
from ( select * from rms_client_cell ) a
LEFT JOIN ( select * from rms_medicament ) b on a . client_id = b . client_id and a . cell_speci = b . flow_position_cod e
LEFT JOIN ( select * from rms_medicament ) b on a . client_id = b . client_id and a . cell_speci = b . plac e
GROUP BY a . id
) c LEFT JOIN ( select * from rms_client where func_type = { func_type } ) d on c . client_id = d . client_id
where d . client_name is not null
@ -282,30 +308,29 @@ class BllMedicament(Repository):
# 药剂入库
def drugPutIn ( self , entityDrug = EntityMedicament ( ) , entityClient = EntityClient ( ) , entityUser = EntityUser ( ) ) :
entityDrugRecord = EntityMedicamentRecord (
customer_id = entityClient . customer_id ,
client_id = entityClient . client_id ,
client_code = entityClient . client_code ,
variety_id = entityDrug . variety_id ,
medicament_id = entityDrug . medicament_id ,
price = entityDrug . price ,
record_type = DrugRecordType . PutIn ,
record_remain = float ( entityDrug . remain ) ,
is_empty = 0 ,
create_date = Utils . get_str_datetime ( ) ,
create_user_id = entityUser . user_id ,
create_user_name = entityUser . real_name ,
)
if entityClient . client_id not in client_list :
entityDrugRecord = EntityMedicamentRecord (
customer_id = entityClient . customer_id ,
client_id = entityClient . client_id ,
client_code = entityClient . client_code ,
variety_id = entityDrug . variety_id ,
medicament_id = entityDrug . medicament_id ,
price = entityDrug . price ,
record_type = DrugRecordType . PutIn ,
record_remain = float ( entityDrug . remain ) ,
is_empty = 0 ,
create_date = Utils . get_str_datetime ( ) ,
create_user_id = entityUser . user_id ,
create_user_name = entityUser . real_name ,
)
# 创建事务
self . beginTrans ( )
entityDrug . remark30 = ' 0 '
entityDrug . client_code = entityClient . client_code
self . session . add ( entityDrug )
if entityDrug . status == 1 :
if entityDrug . status == 1 and entityClient . client_id not in client_list :
self . session . add ( entityDrugRecord )
boolean_ = self . commitTrans ( )
if boolean_ is None :
@ -317,23 +342,23 @@ class BllMedicament(Repository):
self . beginTrans ( )
entityDrug . remark30 = ' 0 '
self . session . merge ( entityDrug )
entityDrugRecord = EntityMedicamentRecord (
customer_id= entityClient . customer_id ,
client_id = entityClient . client _id,
client_code = entityClient . client_code ,
variety_id = entityDrug . variety_id ,
medicament_id = entityDrug . medicament _id,
price = entityDrug . price ,
record_type = DrugRecordType . Us e,
is_empty = 0 ,
record_remain = float ( entityDrug . remain ) ,
create_date = Utils . get_str_datetime ( ) ,
create_user_id = entityUser . user_id ,
create_user_name = entityUser . real_name ,
)
if entityClient . client_id not in client_list :
entityDrugRecord = EntityMedicamentRecord (
customer_id = entityClient . customer _id,
client_id = entityClient . client_id ,
client_code = entityClient . client_code ,
variety_id = entityDrug . variety _id,
medicament_id = entityDrug . medicament_id ,
price = entityDrug . pric e,
record_type = DrugRecordType . Use ,
is_empty = 0 ,
record_remain = float ( entityDrug . remain ) ,
create_date = Utils . get_str_datetime ( ) ,
create_user_id = entityUser . user_id ,
create_user_name = entityUser . real_name ,
)
self . session . add ( entityDrugRecord )
self . session . add ( entityDrugRecord )
entityVariety = BllMedicamentVariety ( ) . findEntity ( entityDrug . variety_id )
entityVariety . normal_count - = 1
entityVariety . use_count + = 1
@ -349,24 +374,27 @@ class BllMedicament(Repository):
drug = BllMedicament ( ) . findEntity ( entityDrug . medicament_id )
lastRemain = float ( drug . remain )
if not entityDrug . remain :
entityDrug . remain = 0
if entityClient . client_id not in client_list :
entityDrugRecord = EntityMedicamentRecord (
customer_id = entityClient . customer_id ,
client_id = entityClient . client_id ,
client_code = entityClient . client_code ,
variety_id = entityDrug . variety_id ,
medicament_id = entityDrug . medicament_id ,
price = entityDrug . price ,
use_quantity = float ( lastRemain ) - float ( entityDrug . remain if entityDrug . remain else 0 ) ,
record_type = DrugRecordType . Return ,
record_remain = float ( entityDrug . remain ) ,
is_empty = 1 if ( entityDrug . status == DrugStatus . Empty ) else 0 ,
create_date = Utils . get_str_datetime ( ) ,
create_user_id = entityUser . user_id ,
create_user_name = entityUser . real_name ,
entityDrugRecord = EntityMedicamentRecord (
customer_id = entityClient . customer_id ,
client_id = entityClient . client_id ,
client_code = entityClient . client_code ,
variety_id = entityDrug . variety_id ,
medicament_id = entityDrug . medicament_id ,
price = entityDrug . price ,
use_quantity = float ( lastRemain ) - float ( entityDrug . remain if entityDrug . remain else 0 ) ,
record_type = DrugRecordType . Return ,
record_remain = float ( entityDrug . remain ) ,
is_empty = 1 if ( entityDrug . status == DrugStatus . Empty ) else 0 ,
create_date = Utils . get_str_datetime ( ) ,
create_user_id = entityUser . user_id ,
create_user_name = entityUser . real_name ,
)
self . session . add ( entityDrugRecord )
)
self . session . add ( entityDrugRecord )
entityVariety = BllMedicamentVariety ( ) . findEntity ( entityDrug . variety_id )
if ( entityDrug . remain != 0 ) :
entityVariety . normal_count + = 1
@ -411,6 +439,7 @@ class BllMedicament(Repository):
sql_all = f """
select * from rms_medicament where status = { status } and func_type = ' {func_type} ' and by_user_id = ' {user.user_id} ' order by by_user_date desc
"""
print ( sql_all , ' 00909 ' )
try :
count_number = len ( self . execute ( sql_all ) . fetchall ( ) )
except :
@ -684,25 +713,34 @@ class BllMedicament(Repository):
# 获取待入库and待归还试剂数据
def get_drug_type_list ( self , status , client_id , page_param , user ) :
def get_drug_type_list ( self , status , client_id , page_param , user _id ) :
filter_base = " "
if status :
filter_base + = f " status= { status } "
if filter_base :
filter_base + = " and "
if status == 5 :
filter_base + = f " put_in_user_id= ' { user . user _id} ' "
filter_base + = f " put_in_user_id= ' { user _id} ' "
else :
filter_base + = f " by_user_id= ' { user . user _id} ' "
if client_id :
filter_base + = f " by_user_id= ' { user _id} ' "
if client_id == ' 72e70542-b70d-11e8-aea5-448a5bc6c411 ' :
if filter_base :
filter_base + = " and "
filter_base + = f " client_id= ' { client_id } ' "
filter_base + = f " client_id in ( ' 72e70542-b70d-11e8-aea5-448a5bc6c411 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c412 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c413 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c414 ' ) "
if client_id == ' 72e70542-b70d-11e8-aea5-448a5bc6c415 ' :
if filter_base :
filter_base + = " and "
filter_base + = f " client_id in ( ' 72e70542-b70d-11e8-aea5-448a5bc6c415 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c416 ' ) "
if client_id == ' 72e70542-b70d-11e8-aea5-448a5bc6c417 ' :
if filter_base :
filter_base + = " and "
filter_base + = f " client_id in ( ' 72e70542-b70d-11e8-aea5-448a5bc6c417 ' ) "
if filter_base :
filter_base = f " where { filter_base } "
sql_all = f """
select * from rms_medicament { filter_base }
"""
print ( sql_all )
try :
count_number = self . execute ( f " select count(*) num from rms_medicament { filter_base } " ) . fetchone ( ) . num
except Exception :
@ -712,7 +750,16 @@ class BllMedicament(Repository):
sql_all = Utils . sql_paging_assemble ( sql_all , page_param )
return self . execute ( sql_all ) . fetchall ( )
# 获取待入库and待归还试剂数据
def get_drug_type_list2 ( self , user_id ) :
sql_all = f """
select * from rms_medicament where client_id in ( ' 72e70542-b70d-11e8-aea5-448a5bc6c411 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c412 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c413 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c414 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c415 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c416 ' , ' 72e70542-b70d-11e8-aea5-448a5bc6c417 ' ) and ( ( status = 5 and put_in_user_id = ' {user_id} ' ) or ( status = 2 and by_user_id = ' {user_id} ' ) )
"""
data = self . execute ( sql_all ) . fetchall ( )
if data :
return True
else :
return False
def getDrugSetPotionStorageIn ( self , name , clientId = " " ) :