sf新增表面工艺参数同步接口和基础对象,新增dockerfile和requirements.txt文件

This commit is contained in:
gqh
2023-03-14 14:56:18 +08:00
parent fddc8100d6
commit 84ef243b9f
32 changed files with 223 additions and 1262 deletions

View File

@@ -2,7 +2,7 @@
# Part of SmartGo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import api, fields, models
from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__)
@@ -19,29 +19,33 @@ class ResConfigSettings(models.TransientModel):
ftp_password = fields.Char(string='FTP密码')
def sf_all_sync(self):
self.env['sf.production.materials'].sync_all_production_materials()
_logger.info("同步资源库材料")
self.env['sf.materials.model'].sync_all_materials_model()
_logger.info("同步资源库材料型号")
self.env['sf.production.process'].sync_all_production_process()
_logger.info("同步资源库表面工艺")
self.env['sf.processing.technology'].sync_all_processing_technology()
_logger.info("同步资源库加工工艺")
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
_logger.info("同步资源库品牌类别")
self.env['sf.machine.brand'].sync_all_machine_brand()
_logger.info("同步资源库品牌")
self.env['sf.machine.control_system'].sync_all_machine_tool_type_control_system()
_logger.info("同步资源库控制系统")
# self.env['sf.machine_tool'].sync_all_machine_tool()
# _logger.info("同步机床行业编码")
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
_logger.info("同步资源库机床型号")
self.env['sf.cutting_tool.category'].sync_all_cutting_tool_category()
_logger.info("同步资源库刀具类别")
self.env['sf.cutting_tool.type'].sync_all_cutting_tool_type()
_logger.info("同步资源库刀具")
# self.env['sf.processing.order'].sync_all_processing_order()
try:
self.env['sf.production.materials'].sync_all_production_materials()
_logger.info("同步资源库材料")
self.env['sf.materials.model'].sync_all_materials_model()
_logger.info("同步资源库材料型号")
self.env['sf.production.process'].sync_all_production_process()
_logger.info("同步资源库表面工艺")
self.env['sf.processing.technology'].sync_all_processing_technology()
_logger.info("同步资源库加工工艺")
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
_logger.info("同步资源库品牌类别")
self.env['sf.machine.brand'].sync_all_machine_brand()
_logger.info("同步资源库品牌")
self.env['sf.machine.control_system'].sync_all_machine_tool_type_control_system()
_logger.info("同步资源库控制系统")
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
_logger.info("同步资源库机床型号")
self.env['sf.cutting_tool.category'].sync_all_cutting_tool_category()
_logger.info("同步资源库刀具类别")
self.env['sf.cutting_tool.type'].sync_all_cutting_tool_type()
_logger.info("同步资源库刀具")
self.env['sf.production.process.parameter'].sync_all_production_process_parameter()
_logger.info("同步表面工艺参数")
except Exception as e:
_logger.info("捕获错误信息:%s" % e)
raise ValidationError("数据错误导致同步失败,请联系管理员")
@api.model
def get_values(self):

View File

@@ -948,3 +948,75 @@ class sfProcessingOrder(models.Model):
})
else:
raise ValidationError("认证未通过")
class sfProductionProcessParameter(models.Model):
_inherit = 'sf.production.process.parameter'
_description = '表面工艺可选参数'
url = '/api/production_process_parameter/list'
# 定时同步每日表面工艺
def sync_production_process_parameter(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
headers = Common.get_headers(self, token, sf_secret_key)
strUrl = sf_sync_config['sf_url'] + 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['mrs_production_process_parameter_yesterday_list']:
if item:
brand = self.env['sf.production.process.parameter'].search(
[("code", '=', item['code'])])
if brand:
brand.name = item['name'],
brand.code = item['code'],
brand.active = item['active'],
brand.price = item['price'],
else:
self.env['sf.production.process.parameter'].create({
"name": item['name'],
"code": item['code'],
"active": item['active'],
"price" : item['price'],
"process_id": self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])]).id,
'materials_model_ids': self.env['sf.materials.model'].search(
[('materials_no', 'in', item['materials_model_ids_codes'])])
})
else:
raise ValidationError("认证未通过") # 定时同步表面工艺
# 同步所有表面工艺
def sync_all_production_process_parameter(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
sf_secret_key = sf_sync_config['sf_secret_key']
headers = Common.get_headers(self, token, sf_secret_key)
strUrl = sf_sync_config['sf_url'] + 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['mrs_production_process_parameter_all_list']:
if item:
brand = self.env['sf.production.process.parameter'].search(
[("code", '=', item['code'])])
if not brand:
self.env['sf.production.process.parameter'].create({
"name": item['name'],
"code": item['code'],
"price": item['price'],
"active": item['active'],
"process_id": self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])]).id,
'materials_model_ids': self.env['sf.materials.model'].search(
[('materials_no', 'in', item['materials_model_ids_codes'])])
})
else:
raise ValidationError("认证未通过")