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.
55 lines
1.7 KiB
55 lines
1.7 KiB
#!/usr/bin/env python
|
|
# -*- encoding: utf-8 -*-
|
|
'''
|
|
@Date:2022/08/08 15:17:46
|
|
'''
|
|
import sys
|
|
sys.path.append('.')
|
|
|
|
from sqlalchemy import and_
|
|
|
|
from db_logic.db_base import Repository
|
|
from models.msds_dangerous_models import EntityMsDs
|
|
from Common.Utils import Utils
|
|
#用户操作业务逻辑类
|
|
|
|
|
|
class BllMsDs(Repository):
|
|
|
|
def __init__(self, entityType=EntityMsDs):
|
|
super().__init__(entityType)
|
|
|
|
def get_seach_list(self, seach_word, page_param):
|
|
filter_base = ""
|
|
if 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"""
|
|
select * from rms_msds {filter_base}
|
|
"""
|
|
try:
|
|
count_number = self.execute(f"select count(*) num from rms_msds {filter_base}").fetchone().num
|
|
except Exception:
|
|
count_number = 0
|
|
page_param.totalRecords=count_number
|
|
page_sql = Utils.sql_paging_assemble(sql_all, page_param)
|
|
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() |