提交同步代码
This commit is contained in:
@@ -32,7 +32,6 @@ class MachineBrand(models.Model):
|
|||||||
tag_ids = fields.Many2many('mrs.machine.brand.tags', 'rel_machine_brand_tags', string='类别')
|
tag_ids = fields.Many2many('mrs.machine.brand.tags', 'rel_machine_brand_tags', string='类别')
|
||||||
image_brand = fields.Image("品牌图片")
|
image_brand = fields.Image("品牌图片")
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
code = fields.Char('编码')
|
code = fields.Char('编码')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class MrsProductionMaterials(models.Model):
|
|||||||
partner_ids = fields.Many2many('res.partner', 'materials_ids', '加工工厂')
|
partner_ids = fields.Many2many('res.partner', 'materials_ids', '加工工厂')
|
||||||
materials_model_ids = fields.One2many('mrs.materials.model', 'materials_id', '材料型号')
|
materials_model_ids = fields.One2many('mrs.materials.model', 'materials_id', '材料型号')
|
||||||
materials_no = fields.Char("编码")
|
materials_no = fields.Char("编码")
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
# 材料型号
|
# 材料型号
|
||||||
@@ -28,6 +29,7 @@ class MrsMaterialModel(models.Model):
|
|||||||
materials_id = fields.Many2one('mrs.production.materials', "材料名")
|
materials_id = fields.Many2one('mrs.production.materials', "材料名")
|
||||||
materials_num = fields.Char("编码号")
|
materials_num = fields.Char("编码号")
|
||||||
material_no = fields.Char("编码")
|
material_no = fields.Char("编码")
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
# 工艺 编码,名称,备注
|
# 工艺 编码,名称,备注
|
||||||
@@ -37,9 +39,10 @@ class MrsProductionProcess(models.Model):
|
|||||||
name = fields.Char('表面工艺')
|
name = fields.Char('表面工艺')
|
||||||
remark = fields.Text("备注")
|
remark = fields.Text("备注")
|
||||||
processing_technology_ids = fields.Many2many('mrs.processing.technology', 'mrs_associated_processes',
|
processing_technology_ids = fields.Many2many('mrs.processing.technology', 'mrs_associated_processes',
|
||||||
index=True)
|
index=True)
|
||||||
partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂')
|
partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂')
|
||||||
process_encode = fields.Char("编码")
|
process_encode = fields.Char("编码")
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
class MrsProcessingTechnology(models.Model):
|
class MrsProcessingTechnology(models.Model):
|
||||||
@@ -52,6 +55,7 @@ class MrsProcessingTechnology(models.Model):
|
|||||||
process_encode = fields.Char("编码")
|
process_encode = fields.Char("编码")
|
||||||
production_process_ids = fields.Many2many('mrs.production.process', 'mrs_associated_processes',
|
production_process_ids = fields.Many2many('mrs.production.process', 'mrs_associated_processes',
|
||||||
index=True)
|
index=True)
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
|
||||||
class ProductTemplate(models.Model):
|
class ProductTemplate(models.Model):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding='UTF-8'?>
|
<?xml version="1.0" encoding='UTF-8'?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record model="ir.cron" id="sf_cron">
|
<record model="ir.cron" id="sf_cron1">
|
||||||
<field name="name">同步资源库材料</field>
|
<field name="name">同步资源库材料</field>
|
||||||
<field name="model_id" ref="model_mrs_production_materials"/>
|
<field name="model_id" ref="model_mrs_production_materials"/>
|
||||||
<field name="state">code</field>
|
<field name="state">code</field>
|
||||||
@@ -10,4 +10,116 @@
|
|||||||
<field name="numbercall">-1</field>
|
<field name="numbercall">-1</field>
|
||||||
<field name="doall" eval="False"/>
|
<field name="doall" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron2">
|
||||||
|
<field name="name">同步资源库材料型号</field>
|
||||||
|
<field name="model_id" ref="model_mrs_materials_model"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_materials_model()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron3">
|
||||||
|
<field name="name">同步资源库表面工艺</field>
|
||||||
|
<field name="model_id" ref="model_mrs_production_process"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_production_process()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron4">
|
||||||
|
<field name="name">同步资源库加工工艺</field>
|
||||||
|
<field name="model_id" ref="model_mrs_processing_technology"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_processing_technology()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron5">
|
||||||
|
<field name="name">同步资源库标签</field>
|
||||||
|
<field name="model_id" ref="model_mrs_machine_brand_tags"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_machine_brand_tags()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron6">
|
||||||
|
<field name="name">同步资源库控制系统</field>
|
||||||
|
<field name="model_id" ref="model_mrs_machine_tool_type_control_system"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_machine_tool_type_control_system()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron7">
|
||||||
|
<field name="name">同步资源库品牌</field>
|
||||||
|
<field name="model_id" ref="model_mrs_machine_brand"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_machine_brand()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron8">
|
||||||
|
<field name="name">同步资源库机床</field>
|
||||||
|
<field name="model_id" ref="model_mrs_machine_tool"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_machine_tool()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron9">
|
||||||
|
<field name="name">同步资源库机床型号</field>
|
||||||
|
<field name="model_id" ref="model_mrs_machine_tool_type"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_machine_tool_type()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron10">
|
||||||
|
<field name="name">同步资源库刀具类别</field>
|
||||||
|
<field name="model_id" ref="model_mrs_cutting_tool_category"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_cutting_tool_category()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="sf_cron11">
|
||||||
|
<field name="name">同步资源库刀具型号</field>
|
||||||
|
<field name="model_id" ref="model_mrs_cutting_tool_type"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.sync_cutting_tool_type()</field>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="doall" eval="False"/>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -7,6 +7,7 @@ from datetime import timedelta, datetime
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
import hashlib
|
||||||
import datetime
|
import datetime
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
@@ -15,6 +16,20 @@ import logging
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
MRS = 'https://mrs.cs.jikimo.com'
|
MRS = 'https://mrs.cs.jikimo.com'
|
||||||
|
# MRS = 'http://192.168.50.11:8069'
|
||||||
|
|
||||||
|
TOKEN = '9524cba0-3e39-11ed-84ab-0242ac110003'
|
||||||
|
# TOKEN = '999e2cff-3e44-11ed-92e2-f8b54d90e788'
|
||||||
|
mrs_secret_key = 'HcSd4zh5AofCm73W'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# TIMESTAMP = str(int(time.time()))
|
||||||
|
# check_str = '9524cba0-3e39-11ed-84ab-0242ac110003'+TIMESTAMP+'NIl6j3knJdhvUWKy'
|
||||||
|
# check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
# HEADERS = {'TOKEN': '9524cba0-3e39-11ed-84ab-0242ac110003',
|
||||||
|
# 'TIMESTAMP': "",
|
||||||
|
# 'check_str': check_mrs_str}
|
||||||
|
|
||||||
|
|
||||||
class MrsProductionMaterials(models.Model):
|
class MrsProductionMaterials(models.Model):
|
||||||
@@ -22,72 +37,445 @@ class MrsProductionMaterials(models.Model):
|
|||||||
_description = "材料"
|
_description = "材料"
|
||||||
url = '/api/production_materials/list'
|
url = '/api/production_materials/list'
|
||||||
|
|
||||||
|
# 定时同步材料
|
||||||
def sync_production_materials(self):
|
def sync_production_materials(self):
|
||||||
timestamp_str = int(time.time())
|
timestamp = int(time.time())
|
||||||
headers = {'TOKEN': '4130d97c-37be-11ed-84a7-f8b54df29535',
|
check_str = '%s%s%s' % (TOKEN, timestamp, mrs_secret_key)
|
||||||
'TIMESTAMP': '1663859413',
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
'check_str': 'e840309b4ac386b5b9005dfb85ca9e9eee7149bd'}
|
headers = {'TOKEN': TOKEN,
|
||||||
str = MRS + self.url
|
'TIMESTAMP': str(timestamp),
|
||||||
print(str)
|
'check_str': check_mrs_str}
|
||||||
r = requests.post(str, data=None, json={},headers=headers)
|
|
||||||
|
print(headers)
|
||||||
|
|
||||||
|
r = requests.post((MRS + self.url), json={}, data=None, headers=headers)
|
||||||
r = r.json()
|
r = r.json()
|
||||||
data = json.loads(r['result'])
|
result = json.loads(r['result'])
|
||||||
if data['status'] == 1:
|
if result['status'] == 1:
|
||||||
production_materials_list = data['production_materials_list']
|
for item in result['production_materials_list']:
|
||||||
if production_materials_list:
|
if item:
|
||||||
for item in production_materials_list:
|
brand = self.env['mrs.production.materials'].search(
|
||||||
port = self.env['mrs.production.materials'].search([('materials_no', '=', item.materials_no)])
|
[("id", '=', item['id'])])
|
||||||
if not port:
|
if brand:
|
||||||
port = item
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.production.materials'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"materials_no": item['materials_no'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"active": item['active']
|
||||||
|
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
return "访问失败"
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MrsMaterialModel(models.Model):
|
class MrsMaterialModel(models.Model):
|
||||||
_inherit = 'mrs.materials.model'
|
_inherit = 'mrs.materials.model'
|
||||||
_description = '材料型号'
|
_description = '材料型号'
|
||||||
|
url = '/api/materials_model/list'
|
||||||
|
|
||||||
|
# 定时同步材料型号
|
||||||
|
def sync_materials_model(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
|
||||||
|
print(headers)
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['materials_model_list']:
|
||||||
|
if item:
|
||||||
|
brand = self.env['mrs.materials.model'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.materials.model'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"materials_num": item['materials_num'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"active": item['active'],
|
||||||
|
"materials_id": item['materials_id'],
|
||||||
|
"need_h": item['need_h'],
|
||||||
|
"mf_materia_post": item['mf_materia_post'],
|
||||||
|
"density": item['density'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MrsProductionProcess(models.Model):
|
class MrsProductionProcess(models.Model):
|
||||||
_inherit = 'mrs.production.process'
|
_inherit = 'mrs.production.process'
|
||||||
_description = '表面工艺'
|
_description = '表面工艺'
|
||||||
|
url = '/api/production_process/list'
|
||||||
|
|
||||||
|
# 定时同步表面工艺
|
||||||
|
def sync_production_process(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['production_process_list']:
|
||||||
|
if item:
|
||||||
|
brand = self.env['mrs.production.process'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.production.process'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"process_enstatus": item['process_enstatus'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"active": item['active'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MrsProcessingTechnology(models.Model):
|
class MrsProcessingTechnology(models.Model):
|
||||||
_inherit = 'mrs.processing.technology'
|
_inherit = 'mrs.processing.technology'
|
||||||
_description = '加工工艺'
|
_description = '加工工艺'
|
||||||
|
url = '/api/processing_technology/list'
|
||||||
|
|
||||||
|
# 定时同步加工工艺
|
||||||
|
def sync_processing_technology(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result[' processing_technology_list_all']:
|
||||||
|
if item:
|
||||||
|
brand = self.env['mrs.processing.technology'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.processing.technology'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"process_enstatus": item['process_enstatus'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"active": item['active'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MachineBrandTags(models.Model):
|
class MachineBrandTags(models.Model):
|
||||||
_inherit = 'mrs.machine.brand.tags'
|
_inherit = 'mrs.machine.brand.tags'
|
||||||
_description = '标签'
|
_description = '品牌类别'
|
||||||
|
url = '/api/machine_brand_tags/list'
|
||||||
|
|
||||||
|
# 定时同步品牌类别
|
||||||
|
def sync_machine_brand_tags(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['machine_brand_tags_all_list']:
|
||||||
|
brand = self.env['mrs.machine.brand.tags'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.machine.brand.tags'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"color": item['color'],
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MachineControlSystem(models.Model):
|
class MachineControlSystem(models.Model):
|
||||||
_inherit = 'mrs.machine_tool.type.control_system'
|
_inherit = 'mrs.machine_tool.type.control_system'
|
||||||
_description = '控制系统'
|
_description = '控制系统'
|
||||||
|
url = '/api/machine_control_system/list'
|
||||||
|
|
||||||
|
# 定时同步控制系统
|
||||||
|
def sync_machine_tool_type_control_system(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['machine_control_system_list_all']:
|
||||||
|
if item:
|
||||||
|
brand = self.env['mrs.machine_tool.type.control_system'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.machine_tool.type.control_system'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"status": item['status'],
|
||||||
|
"brand_id": item['brand_id'],
|
||||||
|
"active": item['active'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MachineBrand(models.Model):
|
class MachineBrand(models.Model):
|
||||||
_inherit = 'mrs.machine.brand'
|
_inherit = 'mrs.machine.brand'
|
||||||
_description = '品牌'
|
_description = '品牌'
|
||||||
|
url = '/api/machine_brand/list'
|
||||||
|
|
||||||
|
# 定时同步品牌
|
||||||
|
def sync_machine_brand(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['machine_brand_all_list']:
|
||||||
|
brand = self.env['mrs.machine.brand'].search(
|
||||||
|
[("code", '=', item['code'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.machine.brand'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"code": item['code'],
|
||||||
|
# "image_brand": item['image_brand'],
|
||||||
|
"active": item['active'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MachineTool(models.Model):
|
class MachineTool(models.Model):
|
||||||
_inherit = 'mrs.machine_tool'
|
_inherit = 'mrs.machine_tool'
|
||||||
_description = '机床'
|
_description = '机床'
|
||||||
|
url = '/api/machine_tool/list'
|
||||||
|
|
||||||
|
# 定时同步机床
|
||||||
|
def sync_machine_tool(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['machine_tool_list']:
|
||||||
|
brand = self.env['mrs.machine_tool'].search(
|
||||||
|
[("code", '=', item['code'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.machine_tool'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"precision": item['precision'],
|
||||||
|
"status": item['status'],
|
||||||
|
"knife_type": item['knife_type'],
|
||||||
|
"registration_date": item['registration_date'],
|
||||||
|
"number_of_knife_library": item['number_of_knife_library'],
|
||||||
|
"rotate_speed": item['rotate_speed'],
|
||||||
|
"number_of_axles": item['number_of_axles'],
|
||||||
|
"control_system_id": item['control_system_id'],
|
||||||
|
"type_id": item['type_id'],
|
||||||
|
"brand_id": item['brand_id'],
|
||||||
|
"x_axis": item['x_axis'],
|
||||||
|
"y_axis": item['y_axis'],
|
||||||
|
"z_axis": item['z_axis'],
|
||||||
|
"b_axis": item['b_axis'],
|
||||||
|
"c_axis": item['c_axis'],
|
||||||
|
"state": item['state'],
|
||||||
|
"active": item['active'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class MachineToolType(models.Model):
|
class MachineToolType(models.Model):
|
||||||
_inherit = 'mrs.machine_tool.type'
|
_inherit = 'mrs.machine_tool.type'
|
||||||
_description = '机床型号'
|
_description = '机床型号'
|
||||||
|
url = '/api/machine_tool_type/list'
|
||||||
|
|
||||||
|
# 定时同步机床型号
|
||||||
|
def sync_machine_tool_type(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['machine_tool_type_list']:
|
||||||
|
brand = self.env['mrs.machine_tool.type'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.machine_tool.type'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"code": item['code'],
|
||||||
|
"brand_id": item['brand_id'],
|
||||||
|
"number_of_knife_library": item['number_of_knife_library'],
|
||||||
|
"rotate_speed": item['rotate_speed'],
|
||||||
|
"machine_tool_id": item['machine_tool_id'],
|
||||||
|
"number_of_axles": item['number_of_axles'],
|
||||||
|
"x_axis": item['x_axis'],
|
||||||
|
"y_axis": item['y_axis'],
|
||||||
|
"z_axis": item['z_axis'],
|
||||||
|
"b_axis": item['b_axis'],
|
||||||
|
"c_axis": item['c_axis'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"precision": item['precision'],
|
||||||
|
"control_system_id": item['control_system_id'],
|
||||||
|
"active": item['active']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class CuttingTool(models.Model):
|
class CuttingTool(models.Model):
|
||||||
_inherit = 'mrs.cutting_tool.category'
|
_inherit = 'mrs.cutting_tool.category'
|
||||||
_description = '刀具类别'
|
_description = '刀具类别'
|
||||||
|
url = '/api/cutting_tool_category/list'
|
||||||
|
|
||||||
|
# 定时同步刀具类别
|
||||||
|
def sync_cutting_tool_category(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['cutting_tool_category_list_all']:
|
||||||
|
brand = self.env['mrs.cutting_tool.category'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.cutting_tool.category'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"status": item['status'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"active": item['active'],
|
||||||
|
# "tag_ids": item['tag_ids']
|
||||||
|
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|
||||||
|
|
||||||
class CuttingToolType(models.Model):
|
class CuttingToolType(models.Model):
|
||||||
_inherit = 'mrs.cutting_tool.type'
|
_inherit = 'mrs.cutting_tool.type'
|
||||||
_description = '刀具型号'
|
_description = '刀具型号'
|
||||||
|
url = '/api/cutting_tool_type/list'
|
||||||
|
|
||||||
|
# 定时同步刀具型号
|
||||||
|
def sync_cutting_tool_type(self):
|
||||||
|
timestamp = str(int(time.time()))
|
||||||
|
check_str = TOKEN + timestamp + mrs_secret_key
|
||||||
|
check_mrs_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
|
headers = {'TOKEN': TOKEN,
|
||||||
|
'TIMESTAMP': timestamp,
|
||||||
|
'check_str': check_mrs_str}
|
||||||
|
strUrl = MRS + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
for item in result['cutting_tool_type_list_all']:
|
||||||
|
brand = self.env['mrs.cutting_tool.type'].search(
|
||||||
|
[("id", '=', item['id'])])
|
||||||
|
if brand:
|
||||||
|
print(item['name'])
|
||||||
|
else:
|
||||||
|
self.env['mrs.cutting_tool.type'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"name": item['name'],
|
||||||
|
"status": item['status'],
|
||||||
|
"remark": item['remark'],
|
||||||
|
"active": item['active'],
|
||||||
|
"diameter": item['diameter'],
|
||||||
|
"cone_angle_pitch": item['cone_angle_pitch'],
|
||||||
|
"shank_diameter": item['shank_diameter'],
|
||||||
|
"long_blade": item['long_blade'],
|
||||||
|
"taper_shank_length": item['taper_shank_length'],
|
||||||
|
"tool_length": item['tool_length'],
|
||||||
|
"blade_number": item['blade_number'],
|
||||||
|
"brand_id": item['brand_id'],
|
||||||
|
"category_id": item['category_id']
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise ValidationError("访问失败")
|
||||||
|
|||||||
Reference in New Issue
Block a user