同步代码

duizhaopin
tangxuan 2 years ago
parent 7f1c1090f0
commit 0e9ffb6db5

@ -42,6 +42,9 @@ class GaoPaiYi():
os.umask(0)
os.makedirs(path)
def __init__(self):
url = "http://localhost:6543/GetAllDisplayInfo"
res = requests.get(url = url)
print(res)
pass
def openCamera(self):
try:
@ -113,10 +116,11 @@ class GaoPaiYi():
# if path:
# self.path = path
#print('----------预览视频-------------------------')
# 打開視頻
url = "http://localhost:6543/StartPreview?dev_idx=0&res_id=0&pixfmt=pixfmt"
res = requests.get(url = url)
# print(json.loads(res.text))
res = requests.get(url = url,timeout=10)
print(json.loads(res.text))
#print(json.loads(res.text)['data'])
# print(json.loads(res.text)['code']=='0')
if json.loads(res.text)['returnCode']!=0:

@ -367,3 +367,6 @@ class CabinetStatus(object):
SignalLightStatus = None # 通信状态是否正常
FilterLifeLightStatus = None # 滤芯寿命是否正常
AbnormalLightStatus = None # 异常灯是否亮
class DooropenUser():
user_id =''

@ -115,7 +115,7 @@ class CreateBarcode:
kwargs.get("purity"),
kwargs.get("standard_code"),
kwargs.get("remark12"),
kwargs.get("flow_position_code"),
kwargs.get("place"),
kwargs.get("file_path"),
)
document.setHtml(html)

@ -22,6 +22,7 @@ from Common.Utils import DrugStatus, PageParam, Utils
from Common.auth import token_auth
from db_logic.user_temporary_auth import BllUserTemporaryAuth
from Common.GaoPaiYi import GaoPaiYi
from Common.Utils import DooropenUser
drug_router = Blueprint("drug", __name__)
@ -42,7 +43,7 @@ def drug_collect():
# 强制使用默认0不强制1强制
force_use = request.values.get("force_use")
force_use = force_use if force_use != '' else '0'
print(bar_code,'55555555555555555555555555555555555555')
# 获取条码试剂
drug_entity = BllMedicament().findEntity(EntityMedicament.bar_code==bar_code)
# 条码实际逻辑判段
@ -118,7 +119,8 @@ def drug_return():
data = Utils.false_return(msg="试剂不属于这里当前管理")
else:
# 药剂归还,进入归还事务处理
drug_info.status = DrugStatus.Normal
if drug_info.client_id not 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']:
drug_info.status = DrugStatus.Normal
drug_info.remain = remain
# if place:
# drug_info.client_id = place
@ -157,7 +159,7 @@ def get_drug_info():
bar_code, new_code = Utils.get_bar_code_reverse(bar_code)
data = BllMedicament().execute(
f"select * from rms_medicament where func_type={func_type} and (bar_code like '%{bar_code}%' or bar_code like '%{new_code}%') "
).fetchall()
).fetchall()
data = Utils.msyql_table_model(data)
if data:
return jsonify(Utils.true_return(data=data[0]))
@ -342,6 +344,16 @@ def get_msds_list():
data_list = BllMsDs().get_seach_list(seach_word=seach_word, page_param=page_param)
return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list), "total_cout": page_param.totalRecords}))
# msds数据展示
@drug_router.route("/get_msds_drug", methods=["GET", "POST"])
@token_auth.login_required
def get_msds_drug():
seach_word = request.values.get("seach_word")
cas_number = request.values.get("cas_number")
data_list = BllMsDs().get_seach(seach_word=seach_word,cas=cas_number)
if data_list:
return jsonify(Utils.true_return(data={"data_list": Utils.msyql_table_model(data_list)}))
return jsonify(Utils.true_return(data={"data_list": []}))
# 危化品数据展示
@drug_router.route("/dangerous_db_list", methods=["GET", "POST"])
@ -449,16 +461,14 @@ def del_medicament_image():
# 待入库试剂信息and 待归还试剂信息
@drug_router.route("/stay_putin_return_list", methods=["POST"])
@token_auth.login_required
@drug_router.route("/stay_putin_return_list", methods=["POST",'GET'])
def get_stay_putin_list():
client_id = request.values.get("client_id")
page = request.values.get("page")
page_size = request.values.get("page_size")
page = request.values.get("page",'1')
page_size = request.values.get("page_size",'10000')
status = request.values.get("status")
page_param = PageParam(int(page), int(page_size))
data = BllMedicament().get_drug_type_list(status=int(status), client_id=client_id, page_param=page_param, user=g.current_user)
data = BllMedicament().get_drug_type_list(status=int(status), client_id=client_id, page_param=page_param, user_id=DooropenUser.user_id)
data_list = Utils.msyql_table_model(data)
return jsonify(Utils.true_return(data={"data_list":data_list, "total_count": page_param.totalRecords}))
@ -470,10 +480,7 @@ def update_drug_status():
status = request.values.get("status")
bar_code, new_code = Utils.get_bar_code_reverse(bar_code=bar_code)
obj = BllMedicament().findEntity(
and_(
EntityMedicament.bar_code == bar_code,
EntityMedicament.bar_code == new_code
)
EntityMedicament.bar_code == new_code
)
if not obj:
return jsonify(Utils.false_return(msg="试剂信息有误"))

@ -95,6 +95,9 @@ def bind_tmp_input_db():
# client_id = '1c39cb24-07f8-11ed-abd4-f47b094925e1'
bar_code = request.values.get("bar_code")
# user_id = request.values.get("user_id")
bar_code, new_code = Utils.get_bar_code_reverse(bar_code=bar_code)
if func_type ==1 or func_type =='1':
bar_code =new_code
if not bar_code:
return jsonify(Utils.false_return(msg="条码不能为空"))
drug_obj = BllMedicament().findEntity(EntityMedicament.bar_code==bar_code)
@ -136,7 +139,7 @@ def bind_tmp_input_db():
"func_type": func_type,
"remark12":Utils.getDrugUnitCode(num)
}
if len(bar_code) > 10:
if func_type ==1 or func_type =='1':
new_dict["status"] = 5
else:
new_dict["status"] = 1
@ -157,8 +160,8 @@ def bind_tmp_input_db():
# user_id_pt = request.values.get("user_id_pt", '34306da6-0f11-11ed-ba01-009027e3906b')
# BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], auth_type=1)
obj = CreateBarcode()
obj.create_drug_lobel_code(**new_dict)
# obj = CreateBarcode()
# obj.create_drug_lobel_code(**new_dict)
BllMedicament().drugPutIn(
drug_entity,
BllClient().findEntity(EntityClient.client_id==drug_entity.client_id),

@ -19,6 +19,7 @@ from models.medicament_models import EntityMedicament
from models.power_models import EntityUserApply, EntityUserTemporaryAuth
from Common.Utils import Utils, PageParam
from Common.auth import token_auth
from Common.Utils import DooropenUser
temporary_bp = Blueprint("temporary_auth", __name__)
@ -181,6 +182,8 @@ def get_register_drug():
@token_auth.login_required
def set_register():
bar_code = request.values.get("bar_code")
is_empty = request.values.get("is_empty",0)
print(bar_code,'1111111111111111111111111111')
bar_code, new_code = Utils.get_bar_code_reverse(bar_code)
obj = BllMedicament().findEntity(
or_(
@ -199,7 +202,11 @@ def set_register():
if not obj.remark13:
setattr(obj, "remark13", Utils.get_str_datetime())
setattr(obj, "remain", remain)
setattr(obj, "status", 2)
# print(is_empty==0,'777777777777777777777777')
if int(is_empty) ==0:
setattr(obj, "status", 2)
else:
setattr(obj, "status", 3)
BllMedicament().update(obj)
# 登记
BllUserApply().update_use_content(client_id=obj.client_id, user=g.current_user, drug_info=obj)
@ -215,8 +222,7 @@ def set_register():
# 获取待领用试剂列表
@temporary_bp.route("/get_stay_use_list", methods=["GET", "POST"])
@token_auth.login_required
def get_stay_use_list():
client_id = request.values.get("client_id")
data_list = BllUserApply().get_stay_use_list(client_id=client_id, user=g.current_user)
data_list = BllUserApply().get_stay_use_list(client_id=client_id, user_id=DooropenUser.user_id)
return jsonify(Utils.true_return(data=data_list))

@ -7,9 +7,15 @@ from flask import jsonify, request, Blueprint, g
from sqlalchemy import and_
from Common.auth import token_auth
from Common.Utils import PageParam, Utils
from io import BytesIO
from db_logic.user import BllUser
from models.user_models import EntityUser
from models.user_models import EntityUser,EntityRole,EntityUserFace
from models.power_models import EntityUserApply
from db_logic.user_apply import BllUserApply
from db_logic.medicament import BllMedicament
from db_logic.role import BllRole
from db_logic.user_face import BllUserFace
from Common.Utils import DooropenUser
user_router = Blueprint('user', __name__)
@ -51,19 +57,23 @@ def user_update_password():
def get_user_info_list():
user_code = request.values.get("user_code")
real_name = request.values.get("real_name")
role_name = request.values.get("role_name")
role_id = request.values.get("role_id")
is_enabled = request.values.get("is_enabled")
if role_id:
role =BllRole().findEntity(EntityRole.role_id ==role_id)
role_name=role.role_name
else:
role_name=''
page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size)
data_list = BllUser().get_seach_user_list(
user_id = g.current_user.user_id,
user_code=user_code,
real_name=real_name,
role_name=role_name,
is_enabled=is_enabled,
role_name_self=g.current_user.role_name,
page_param=page_param
)
@ -84,7 +94,9 @@ def add_user_info():
sex=request.values.get("sex"),
email=request.values.get("email"),
user_code=request.values.get("user_code"),
account =request.values.get("user_code"),
qq=request.values.get("qq"),
customer_id ='1002437b-debf-46d6-b186-3e16bcf0cc0f',
role_id=request.values.get("role_id"),
role_name=request.values.get("role_name"),
create_date=Utils.get_str_datetime(),
@ -148,7 +160,36 @@ def del_user():
user_id = request.values.get("user_id")
user_id_list = user_id.split(',')
for i in user_id_list:
# if user_id:
obj = BllUserFace().findEntity(EntityUserFace.user_id==i)
# print(obj.face_value)
if obj:
featureData = BytesIO(b'0000')
obj.face_value = featureData.getvalue()
# obj.user_id =''
# setattr(obj, 'face_value', '')
BllUserFace().update(obj)
BllUser().delete(EntityUser.user_id==i)
return jsonify(Utils.true_return(msg="删除成功"))
# return jsonify(Utils.false_return("未选择用户"))
# 开门逻辑判断
@user_router.route("/opendoorcheck", methods=["GET", "POST"])
def opendoorcheck():
name1 = request.values.get("name1")
name2 = request.values.get("name2")
user1 =BllUser().findEntity(EntityUser.real_name==name1)
user2 =BllUser().findEntity(EntityUser.real_name==name2)
print(user1,user2)
data=False
DooropenUser.user_id =user1.user_id
if user1 and user2:
data=BllUserApply().get_apply_list(user1,user2)
if data:
print(DooropenUser.user_id)
return jsonify(Utils.true_return(msg="请求成功",data=data))
data = BllMedicament().get_drug_type_list2(user_id=user1.user_id)
if data:
DooropenUser.user_id =user1.user_id
return jsonify(Utils.true_return(msg="请求成功",data=data))

@ -6,4 +6,4 @@ port = 9001
# dbconntion = mysql+pymysql://root:123456@127.0.0.1/local_rms_db?charset=utf8
# dbconntion = mysql+pymysql://yanyi:tangyan86910282@111.231.67.55/yy_rms_multiple?charset=utf8
# dbconntion = mysql+pymysql://root:tangyan86910282@127.0.0.1/yy_rms_multiple?charset=utf8
dbconntion = mysql+pymysql://root:123456@127.0.0.1/yy_rms_multiple?charset=utf8
dbconntion = mysql+pymysql://root:123456@192.168.1.200/yy_rms_multiple?charset=utf8

@ -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_code
LEFT JOIN (select * from rms_medicament) b on a.client_id=b.client_id and a.cell_speci=b.place
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.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,
)
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.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=""):

@ -42,12 +42,13 @@ class BllMedicamentRecord(Repository):
filter_base = f" where {filter_base}"
sql_all = f"""
select a.*, b.create_date, b.create_user_name from(
select medicament_id, create_date, create_user_id, create_user_name from rms_medicament_record {filter_base}
select a.*, b.create_date, b.create_user_name,b.record_type from(
select medicament_id, create_date, create_user_id, create_user_name,record_type from rms_medicament_record {filter_base}
) b LEFT JOIN(
select * from rms_medicament {filter_base}
) a on b.medicament_id=a.medicament_id order by create_date desc
"""
print(sql_all,'66666666666666')
# count_sql = "select count(*) from rms_medicament_record"
try:
count_number = len(self.execute(sql_all).fetchall())

@ -22,8 +22,9 @@ class BllMsDs(Repository):
def get_seach_list(self, seach_word, page_param):
filter_base = ""
if seach_word:
seach_word = f"'%{seach_word}%'"
filter_base += f" name like {seach_word} or english_name like {seach_word} "
seach_word1= f"'{seach_word}'"
seach_word = f"'{seach_word}%'"
filter_base += f" name like {seach_word} or english_name like {seach_word} or cas_number = {seach_word1}"
if filter_base:
filter_base = f" where {filter_base} "
sql_all = f"""
@ -35,4 +36,20 @@ class BllMsDs(Repository):
count_number = 0
page_param.totalRecords=count_number
page_sql = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(page_sql).fetchall()
return self.execute(page_sql).fetchall()
def get_seach(self, seach_word,cas=''):
filter_base = ""
if cas:
seach_word = f"'{seach_word}'"
filter_base += f" cas_number = {seach_word} "
else:
if seach_word:
seach_word = f"'{seach_word}'"
filter_base += f" name = {seach_word} or english_name = {seach_word}"
if filter_base:
filter_base = f" where {filter_base} "
sql_all = f"""
select * from rms_msds {filter_base}
"""
return self.execute(sql_all).fetchall()

@ -78,7 +78,7 @@ class BllUser(Repository):
return self.findEntity(payload.get('user_id'))
# 用户管理
def get_seach_user_list(self, user_code, real_name, role_name, is_enabled, page_param, user_id):
def get_seach_user_list(self, user_code, real_name, role_name, is_enabled, page_param, user_id,role_name_self):
filter_base = ""
if user_code:
filter_base += f" user_code like '%{user_code}%'"
@ -94,11 +94,18 @@ class BllUser(Repository):
if filter_base:
filter_base += " and "
filter_base += f" is_enabled={is_enabled}"
# if filter_base:
# filter_base += " and "
# filter_base += f" user_id != '{user_id}' "
# if filter_base:
# filter_base = f" where {filter_base}"
if role_name_self !='管理员':
if filter_base:
filter_base += " and "
filter_base += f" user_id = '{user_id}' "
if filter_base:
filter_base += " and "
filter_base += f" user_id != '{user_id}' "
if filter_base:
filter_base = f" where {filter_base}"
filter_base = f" where {filter_base}"
sql_all = f"""
select * from rms_user {filter_base} order by create_date desc

@ -10,6 +10,9 @@ import json
from db_logic.db_base import Repository
from models.power_models import EntityUserApply
from Common.Utils import Utils
from sqlalchemy import and_
from db_logic.medicament import BllMedicament
from models.medicament_models import EntityMedicament
class BllUserApply(Repository):
@ -65,6 +68,8 @@ class BllUserApply(Repository):
"""
data = self.execute(sql_all).fetchall()
break_bool = True
apply_data=''
num =''
for d in data:
if not break_bool:
break
@ -74,21 +79,40 @@ class BllUserApply(Repository):
if con_info["client_id"] == client_id:
# if con_info["name"] == drug_info.name and con_info["purity"] == drug_info.purity and con_info["speci"] == drug_info.speci:
if con_info["medicament_id"] == drug_info.medicament_id:
if not con_info.get("use_num"):
con_info["use_num"] = 0
if int(con_info["use_num"]) < int(con_info["num"]):
con_info["use_num"] += 1
break_bool = False
obj = self.findEntity(self.entityType.id == d.id)
obj.use_content = json.dumps(use_content)
self.update(obj)
con_info["use_num"] = 1
# if int(con_info["use_num"]) < int(con_info["num"]):
# con_info["use_num"] += 1
break_bool = False
apply_data =d
num =len(use_content)
if apply_data and num:
use_num=0
use_content1 = json.loads(apply_data.use_content)
for i in range(len(use_content1)):
con_info = use_content1[i]
if con_info.get("use_num"):
use_num +=1
obj = self.findEntity(self.entityType.id == d.id)
obj.use_content = json.dumps(use_content)
if use_num >=num:
obj.is_solve =3
#设置申请单完成
self.update(obj)
# 获取待领用列表
def get_stay_use_list(self, client_id, user):
def get_stay_use_list(self, client_id, user_id):
client_list=[client_id]
if client_id =='72e70542-b70d-11e8-aea5-448a5bc6c411':
client_list.extend(['72e70542-b70d-11e8-aea5-448a5bc6c412','72e70542-b70d-11e8-aea5-448a5bc6c413','72e70542-b70d-11e8-aea5-448a5bc6c414'])
if client_id =='72e70542-b70d-11e8-aea5-448a5bc6c415':
client_list.extend(['72e70542-b70d-11e8-aea5-448a5bc6c416'])
print(client_list)
sql_all = f"""
select * from rms_user_apply
where
user_id='{user.user_id}' and
user_id='{user_id}' and
is_solve=1 and
solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
@ -99,9 +123,32 @@ class BllUserApply(Repository):
use_content = json.loads(i.use_content)
for j_index in range(len(use_content)):
j = use_content[j_index]
if j["client_id"] != client_id:
if j["client_id"] not in client_list:
continue
# if j.get("use_num") != 0:
j["stay_use_num"] = j.get("use_num")
data_list.append(j)
if not j.get("use_num"):
# j["stay_use_num"] = j.get("use_num")
drugobj =BllMedicament().findEntity(and_(EntityMedicament.status==1,EntityMedicament.medicament_id == j.get("medicament_id")))
print(drugobj,'889898989898989')
if drugobj:
data_list.append(j)
print(data_list)
return data_list
def get_apply_list(self,user1,user2):
print(user1,user2)
sql_all = f"""
select * from rms_user_apply
where
user_id='{user1.user_id}' and user_id_pt='{user2.user_id}' and
is_solve=1 and
solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
"""
print(sql_all)
data = self.execute(sql_all).fetchall()
print(data)
if data:
return True
else:
return False
Loading…
Cancel
Save