| | |
| | | # |
| | | #设备收益 |
| | | class Profit(Base): |
| | | __tablename__ = 'aijuke_device_profit_log' |
| | | __tablename__ = 'tz_device_profit_log' |
| | | |
| | | id = Column(Integer, primary_key=True, autoincrement=True, comment='主键,自增ID') |
| | | device_name = Column(String(255), nullable=True, comment='设备别名') |
| | |
| | | print("date:", date) |
| | | create_time = time.strftime("%Y-%m-%d %H:%M:%S", localTime) |
| | | print("createTime:", create_time) |
| | | |
| | | #写入数据库 |
| | | profit = Profit( |
| | | device_name= summary_device_name if summary_device_name else None, |
| | | income = summary_income if summary_income else None, |
| | |
| | | date_time = create_time if create_time else None, |
| | | # date_time= create_time if create_time else None |
| | | ) |
| | | add_profit(profit) |
| | | #add_profit(profit) |
| | | #调用流量牛api同步数据 |
| | | headers4lln = { |
| | | "Accept": "*/*", |
| | | "Accept-Encoding": "gzip, deflate, br", |
| | | "Accept-Language": "zh-CN,zh;q=0.9", |
| | | "Connection": "keep-alive", |
| | | "Content-Type": "application/json", |
| | | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " |
| | | "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36" |
| | | } |
| | | add_profit_api = 'https://www.my1618.com.cn/api2/tests/insertIncome' |
| | | params_value = {"deviceProfitLogs": [ {'deviceName': summary_device_name, 'income': summary_income, 'date': date, 'dateTime': create_time} ] } |
| | | resp_add_profit_api = requests.post(add_profit_api, json=params_value, headers=headers4lln) |
| | | resp_text_add_profit_api = resp_add_profit_api.text |
| | | print("======https://www.my1618.com.cn/api2/tests/insertIncome response result=======") |
| | | print(resp_text_add_profit_api) |
| | | |
| | | except Exception as e: |
| | | print(e) |