@ -26,7 +26,7 @@ class BllMedicamentVariety(Repository):
return super ( ) . __init__ ( entityType )
# 创建药剂品种
def createDrugVariety ( self , customer_id , drug_info , user_info ):
def createDrugVariety ( self , customer_id , drug_info , user_info , func_type ):
entity = self . findEntity (
and_ (
EntityMedicamentVariety . name == drug_info . get ( " name " ) ,
@ -55,7 +55,8 @@ class BllMedicamentVariety(Repository):
normal_count = 1 ,
use_count = 0 ,
empty_count = 0 ,
is_supervise = 0
is_supervise = 0 ,
remark1 = func_type ,
)
self . insert ( entity )
else :
@ -74,10 +75,10 @@ class BllMedicamentVariety(Repository):
if func_type :
if filter_base :
filter_base + = " and "
filter_base + = f " tp = { func_type } "
filter_base + = f " remark1 = { func_type } "
if filter_base :
filter_base = f " where { filter_base } "
sql_all = f """
select * from rms_medicament_variety { filter_base }
"""
@ -89,12 +90,12 @@ class BllMedicamentVariety(Repository):
if page_param :
page_param . totalRecords = count_number
sql_all = Utils . sql_paging_assemble ( sql_all , page_param )
return self . execute ( sql_all ) . fetchall ( )
return self . execute ( sql_all ) . fetchall ( )
# # 获取品种统计
# def getVarietyStatistics(self):
# SQL = """
# SELECT b.VarietyId as VarietyId, COUNT(CASE when IsEmpty = 1 then 1 end) as QuarterlyEmptyCount,
# sum(CASE when IsEmpty = 1 then a.price else 0 end) as QuarterlyEmptyPrice, COUNT(CASE when RecordType = 1 then 1 end) as
# SELECT b.VarietyId as VarietyId, COUNT(CASE when IsEmpty = 1 then 1 end) as QuarterlyEmptyCount,
# sum(CASE when IsEmpty = 1 then a.price else 0 end) as QuarterlyEmptyPrice, COUNT(CASE when RecordType = 1 then 1 end) as
# QuarterlyPutInCount from RMS_MedicamentVariety as b LEFT JOIN RMS_MedicamentRecord as a on
# b.VarietyId = a.VarietyId and MONTH((a.CreateDate)) = MONTH(now()) and Date_format
# (a.CreateDate, '%Y') = (DATE_FORMAT(now(), '%Y')) GROUP by b.VarietyId
@ -103,10 +104,10 @@ class BllMedicamentVariety(Repository):
# quarter_data = BllMedicamentVariety().execute(SQL).fetchall()
# quarter_data = json.loads(Utils.resultAlchemyData(
# Utils.mysqlTable2Model(quarter_data)))
# SQL = """SELECT b.VarietyId as VarietyId, COUNT(CASE when IsEmpty = 1 then a.CreateDate end)
# SQL = """SELECT b.VarietyId as VarietyId, COUNT(CASE when IsEmpty = 1 then a.CreateDate end)
# as YearEmptyCount, sum(CASE when IsEmpty = 1 then a.price else 0 end) as YearEmptyPrice,
# COUNT(CASE when RecordType = 1 then 1 end) as YearPutInCount from RMS_MedicamentVariety as b LEFT JOIN
# RMS_MedicamentRecord as a on b.VarietyId = a.VarietyId and year((a.CreateDate)) =
# COUNT(CASE when RecordType = 1 then 1 end) as YearPutInCount from RMS_MedicamentVariety as b LEFT JOIN
# RMS_MedicamentRecord as a on b.VarietyId = a.VarietyId and year((a.CreateDate)) =
# year(now()) GROUP by b.VarietyId"""
# # 获取年度数据
@ -114,11 +115,11 @@ class BllMedicamentVariety(Repository):
# year_data = json.loads(Utils.resultAlchemyData(
# Utils.mysqlTable2Model(year_data)))
# SQL = """
# select a.VarietyId as VarietyId, a.Name,a.Purity,a.CASNumber,a.IsSupervise,
# sum(case when b.`Status` = 1 then 1 else 0 end) as NormalCount,
# select a.VarietyId as VarietyId, a.Name,a.Purity,a.CASNumber,a.IsSupervise,
# sum(case when b.`Status` = 1 then 1 else 0 end) as NormalCount,
# sum(case when b.`Status` = 1 or b.`Status` = 2 then 1 else 0 end) as TotalCount,
# sum(case when b.`Status` = 2 then 1 else 0 end) as UseCount,
# sum(case when b.`Status` = 1 or b.`Status` = 2 then b.Price else 0 end) as StockPrice
# sum(case when b.`Status` = 2 then 1 else 0 end) as UseCount,
# sum(case when b.`Status` = 1 or b.`Status` = 2 then b.Price else 0 end) as StockPrice
# from RMS_MedicamentVariety as a LEFT JOIN RMS_Medicament
# as b on b.VarietyId = a.VarietyId GROUP BY a.VarietyId
# """
@ -159,4 +160,4 @@ class BllMedicamentVariety(Repository):
# self.insert(obj)
# if __name__ == '__main__':
# BllMedicamentVariety().inster_type_drug()
# BllMedicamentVariety().inster_type_drug()