Files
test/sf_base/commons/common.py
jinling.yang 4f0c7ad274 1.新增机台日计划接口
2.新工件预调(前置三元检测)接口
3.,新NC程序下载接口接口
2024-01-16 17:25:25 +08:00

32 lines
904 B
Python

# -*- coding: utf-8 -*-
import time
import hashlib
from odoo import models
class Common(models.Model):
_name = 'sf.sync.common'
_description = u'公用类'
def get_headers(self, token, secret_key):
'''
获取requests中的heardes参数
'''
timestamp = int(time.time())
check_str = '%s%s%s' % (token, timestamp, secret_key)
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
headers = {'TOKEN': token,
'TIMESTAMP': str(timestamp),
'checkstr': check_sf_str}
return headers
def get_add_time(self, parse_time):
"""
把时间增加8小时
:return:
"""
dt = datetime.datetime.strptime(parse_time, "%Y-%m-%d %H:%M:%S")
d = dt + datetime.timedelta(hours=8)
nTime = d.strftime("%Y-%m-%d %H:%M:%S")
return nTime