You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
5.5 KiB
142 lines
5.5 KiB
#!/usr/bin/env python
|
|
# -*- encoding: utf-8 -*-
|
|
'''
|
|
@Date:2022/07/14 08:39:04
|
|
'''
|
|
import threading
|
|
import datetime
|
|
|
|
from sqlalchemy import and_, or_
|
|
|
|
from Common.utils import Utils
|
|
from Business.Repository import Repository
|
|
from DataEntity.MedicamentModels import EntityMedicamentVariety
|
|
|
|
from DataEntity.UserModels import EntityUser
|
|
|
|
|
|
# 药剂品种业务逻辑类
|
|
class BllMedicamentVariety(Repository):
|
|
_instance_lock = threading.Lock()
|
|
# #实现单例模式
|
|
# def __new__(cls, *args, **kwargs):
|
|
# if not hasattr(BllMedicamentVariety, "_instance"):
|
|
# with BllMedicamentVariety._instance_lock:
|
|
# if not hasattr(BllMedicamentVariety, "_instance"):
|
|
# BllMedicamentVariety._instance = object.__new__(cls)
|
|
# return BllMedicamentVariety._instance
|
|
|
|
def __init__(self, entityType=EntityMedicamentVariety):
|
|
return super().__init__(entityType)
|
|
|
|
# 创建药剂品种
|
|
def createDrugVariety(
|
|
self, customerId, name, english, casNumber,
|
|
purity, total, net_weight_unit, net_weight, tp, entityUser=EntityUser()
|
|
):
|
|
entity = self.findEntity(
|
|
and_(
|
|
EntityMedicamentVariety.name == name,
|
|
EntityMedicamentVariety.purity == purity,
|
|
# EntityMedicamentVariety.Unit == unit,
|
|
# EntityMedicamentVariety.SpeciUnit == speciUnit,
|
|
# EntityMedicamentVariety.Speci == speci
|
|
EntityMedicamentVariety.total == total,
|
|
EntityMedicamentVariety.net_weight_unit == net_weight_unit,
|
|
EntityMedicamentVariety.net_weight == net_weight,
|
|
EntityMedicamentVariety.tp == tp,
|
|
)
|
|
)
|
|
|
|
if(entity is None):
|
|
print(entity, 9999999999999999999)
|
|
entity = EntityMedicamentVariety()
|
|
entity.variety_id = str(Utils.UUID())
|
|
entity.customer_id = customerId
|
|
entity.inventory_warning_value = 10
|
|
entity.shelf_life_warning_value = 10
|
|
entity.use_days_warning_value = 10
|
|
entity.name = name
|
|
entity.english_name = english
|
|
entity.cas_number = casNumber
|
|
entity.purity = purity
|
|
entity.total = total
|
|
entity.net_weight_unit = net_weight_unit
|
|
entity.net_weight = net_weight
|
|
entity.tp = tp
|
|
# 库存总数
|
|
entity.total_count = 1
|
|
# 在库数量
|
|
entity.normal_count = 1
|
|
# 领用数量
|
|
entity.use_count = 0
|
|
# 空瓶数量
|
|
entity.empty_count = 0
|
|
entity.is_supervise = 0
|
|
entity.create_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
entity.create_user_id = entityUser.user_id
|
|
entity.create_user_name = entityUser.real_name
|
|
self.insert(entity)
|
|
# else:
|
|
# # 库存总数 + 1
|
|
# entity.TotalCount += 1
|
|
# # 在库数量 + 1
|
|
# entity.NormalCount += 1
|
|
# self.update(entity)
|
|
entity = self.session.merge(entity)
|
|
return entity
|
|
|
|
# 模糊查询根据药剂名称或英文名称查询
|
|
|
|
def findEnglishOrChinseNameList(self, params):
|
|
return self.findList(or_(EntityMedicamentVariety.name.like('%' + params + '%'),
|
|
EntityMedicamentVariety.english_name.like('%' + params + '%')))
|
|
|
|
# #创建药剂品种
|
|
# def createDrugVariety(self, customerId, name, english, casNumber, purity, unit, speciUnit, speci, entityUser=EntityUser()):
|
|
# entity = self.findEntity(and_(EntityMedicamentVariety.Name == name, EntityMedicamentVariety.Purity == purity,
|
|
# EntityMedicamentVariety.Unit == unit, EntityMedicamentVariety.SpeciUnit == speciUnit, EntityMedicamentVariety.Speci == speci))
|
|
|
|
# if(entity is None):
|
|
# print(entity, 9999999999999999999)
|
|
# entity = EntityMedicamentVariety()
|
|
# entity.VarietyId = str(Utils.UUID())
|
|
# entity.CustomerId = customerId
|
|
# entity.InventoryWarningValue = 10
|
|
# entity.ShelfLifeWarningValue = 10
|
|
# entity.UseDaysWarningValue = 10
|
|
# entity.Name = name
|
|
# entity.EnglishName = english
|
|
# entity.CASNumber = casNumber
|
|
# entity.Purity = purity
|
|
# entity.Unit = unit
|
|
# entity.SpeciUnit = speciUnit
|
|
# # 库存总数
|
|
# entity.TotalCount = 1
|
|
# # 在库数量
|
|
# entity.NormalCount = 1
|
|
# # 领用数量
|
|
# entity.UseCount = 0
|
|
# # 空瓶数量
|
|
# entity.EmptyCount = 0
|
|
# entity.IsSupervise = 0
|
|
# entity.Speci = speci
|
|
# entity.CreateDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
# entity.CreateUserId = entityUser.UserId
|
|
# entity.CreateUserName = entityUser.RealName
|
|
# self.insert(entity)
|
|
# # else:
|
|
# # # 库存总数 + 1
|
|
# # entity.TotalCount += 1
|
|
# # # 在库数量 + 1
|
|
# # entity.NormalCount += 1
|
|
# # self.update(entity)
|
|
# entity = self.session.merge(entity)
|
|
# return entity
|
|
|
|
# # 模糊查询根据药剂名称或英文名称查询
|
|
|
|
# def findEnglishOrChinseNameList(self, params):
|
|
# return self.findList(or_(EntityMedicamentVariety.Name.like('%' + params + '%'),
|
|
# EntityMedicamentVariety.EnglishName.like('%' + params + '%')))
|