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.
61 lines
2.4 KiB
61 lines
2.4 KiB
#!/usr/bin/env python
|
|
# -*- encoding: utf-8 -*-
|
|
'''
|
|
@Date:2022/07/13 10:27:10
|
|
'''
|
|
# from Common.Utils import Utils
|
|
from DataEntity.HumitureRecordModels import EntityHumitureRecord
|
|
from Business.Repository import Repository
|
|
import datetime
|
|
|
|
# 功能模块
|
|
|
|
|
|
class BllHumitureRecord(Repository):
|
|
# _instance_lock = threading.Lock()
|
|
# #实现单例模式
|
|
# def __new__(cls, *args, **kwargs):
|
|
# if not hasattr(BllHumitureRecord, "_instance"):
|
|
# with BllHumitureRecord._instance_lock:
|
|
# if not hasattr(BllHumitureRecord, "_instance"):
|
|
# BllHumitureRecord._instance = object.__new__(cls)
|
|
# return BllHumitureRecord._instance
|
|
|
|
def __init__(self, entityType=EntityHumitureRecord):
|
|
return super().__init__(entityType)
|
|
|
|
# 获取温湿度列表
|
|
|
|
def getHumitureList(self, customerId, pageParam):
|
|
queryStr = 'select * from ((select * from rms_humiture_record where client_id=:clientId) '
|
|
queryStr += ' union all (select * from rms_humiture_record where client_id!=:clientId order by client_name ASC ) )t order by t.record_date DESC '
|
|
|
|
queryCountStr = 'select COUNT(*) from ((select * from rms_humiture_record where client_id=:clientId) '
|
|
queryCountStr += ' union all (select * from rms_humiture_record where client_id!=:clientId order by client_name ASC ) )t order by t.record_date DESC '
|
|
# queryParams = {"clientId": CurrentInfo.ClientInfo.client_id}
|
|
queryParams = {"clientId": customerId}
|
|
templateList = self.execute(queryStr + ' limit ' + str((pageParam.curPage-1)
|
|
* pageParam.pageRows)+','+str(pageParam.pageRows), queryParams).fetchall()
|
|
pageParam.totalRecords = self.execute(
|
|
queryCountStr, queryParams).fetchone()[0]
|
|
jsonData = Utils.mysqlTable2Model(templateList)
|
|
return jsonData
|
|
|
|
def insert_one(self, entity):
|
|
self.insert(entity)
|
|
|
|
|
|
# if __name__ == '__main__':
|
|
# for x in range(100000):
|
|
# en = EntityHumitureRecord(
|
|
# record_id=str(Utils.UUID()),
|
|
# device_id='',
|
|
# client_id='72e70542-b70d-11e8-aea5-448a5bc6c418',
|
|
# client_name='1号终端',
|
|
# customer_id='',
|
|
# temperature='30',
|
|
# humidity='50',
|
|
# record_date=datetime.datetime.now(),
|
|
# is_add=1)
|
|
# BllHumitureRecord().insert_one(en)
|