Accept Merge Request #409: (feature/bug修复 -> develop)

Merge Request: 同步cloud资源库静态资源Bug修复及代码优化

Created By: @杨金灵
Accepted By: @杨金灵
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/409?initial=true
This commit is contained in:
杨金灵
2023-10-09 15:23:57 +08:00
committed by Coding
9 changed files with 382 additions and 977 deletions

View File

@@ -257,6 +257,12 @@ div[class="o_content o_component_with_search_panel"] .o_kanban_primary_right > .
top: 55px;
right: 43.5%;
}
//------------------------------------------
.test_model > .o_form_label {
margin-left: 4px !important;
line-height: 0 !important;
}
@media screen and (min-width: 1200px) {
div[class="o_content o_component_with_search_panel"] .o_kanban_primary_right > .row {

View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
import json
import logging
from odoo import http
from odoo.http import request
# class ProductController(http.Controller):
#
# @http.route('/api/cloud/get_cutting_model', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
# cors="*")
# def get_cutting_model(self, **kw):

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import logging
import datetime
import time
from datetime import datetime, timedelta
import hashlib
from odoo import models
from odoo.http import request
@@ -10,8 +9,6 @@ __author__ = 'jinling.yang'
_logger = logging.getLogger(__name__)
class AuthenticationError(Exception):
pass
class AuthenticationError(Exception):
pass
@@ -29,16 +26,18 @@ class Http(models.AbstractModel):
# 查询密钥
factory_secret = request.env['res.partner'].sudo().search(
[('sf_token', '=', datas['HTTP_TOKEN'])], limit=1)
logging.info('factory_secret:%s' % factory_secret)
if not factory_secret:
raise AuthenticationError('无效的token')
timestamp_str = int(time.time())
# 设置API接口请求时间,不能超过5秒
deltime = datetime.timedelta(seconds=5)
# if abs(int(datas['HTTP_TIMESTAMP'])-timestamp_str) > deltime.seconds:
# deltime = datetime.timedelta(seconds=30)
# if abs(int(datas['HTTP_TIMESTAMP']) - timestamp_str) > deltime.seconds:
# raise AuthenticationError('请求已过期')
# 获得sha1_str加密字符串
post_time = int(datas['HTTP_TIMESTAMP'])
datetime_post = datetime.fromtimestamp(post_time)
datetime_now = datetime.now().replace(microsecond=0)
datetime_del = datetime_now + timedelta(seconds=5)
if datetime_post > datetime_del:
raise AuthenticationError('请求已过期')
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
if check_sf_str != datas['HTTP_CHECKSTR']:

View File

@@ -106,7 +106,7 @@
<page string="刀具物料参数" attrs="{'invisible': [('categ_type', '!=', '刀具')]}">
<group>
<group attrs="{'invisible': [('categ_type', '!=', '刀具')]}" col="1">
<field name="cutting_tool_type_id" options="{'no_create': True}" placeholder="请选择"/>
<field name="cutting_tool_type_id" options="{'no_create': True}" placeholder="请选择" />
<field name="brand_id" options="{'no_create': True}" placeholder="请选择"/>
<field name="materials_type_id" options="{'no_create': True}"
attrs="{'invisible': [('cutting_tool_type', 'in', ('整体式刀具','夹头','刀柄'))]}"

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding='UTF-8'?>
<odoo>
<record model="ir.cron" id="sf_cron1">
<field name="name">同步资源库材料</field>
<field name="name">同步静态资源库材料</field>
<field name="model_id" ref="model_sf_production_materials"/>
<field name="state">code</field>
<field name="code">model.sync_production_materials()</field>
@@ -12,7 +12,7 @@
</record>
<record model="ir.cron" id="sf_cron2">
<field name="name">同步资源库材料型号</field>
<field name="name">同步静态资源库材料型号</field>
<field name="model_id" ref="model_sf_materials_model"/>
<field name="state">code</field>
<field name="code">model.sync_materials_model()</field>
@@ -22,8 +22,19 @@
<field name="doall" eval="False"/>
</record>
<record model="ir.cron" id="sf_cron8">
<field name="name">同步静态表面工艺类别</field>
<field name="model_id" ref="model_sf_production_process_category"/>
<field name="state">code</field>
<field name="code">model.sync_production_process_category()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</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="name">同步静态资源库表面工艺</field>
<field name="model_id" ref="model_sf_production_process"/>
<field name="state">code</field>
<field name="code">model.sync_production_process()</field>
@@ -34,7 +45,7 @@
</record>
<record model="ir.cron" id="sf_cron4">
<field name="name">同步资源库加工工艺</field>
<field name="name">同步静态资源库加工工艺</field>
<field name="model_id" ref="model_sf_processing_technology"/>
<field name="state">code</field>
<field name="code">model.sync_processing_technology()</field>
@@ -45,7 +56,7 @@
</record>
<record model="ir.cron" id="sf_cron5">
<field name="name">同步资源库标签</field>
<field name="name">同步静态资源库标签</field>
<field name="model_id" ref="model_sf_machine_brand_tags"/>
<field name="state">code</field>
<field name="code">model.sync_machine_brand_tags()</field>
@@ -56,7 +67,7 @@
</record>
<record model="ir.cron" id="sf_cron6">
<field name="name">同步资源库控系统</field>
<field name="name">同步静态资源库控系统</field>
<field name="model_id" ref="model_sf_machine_control_system"/>
<field name="state">code</field>
<field name="code">model.sync_machine_tool_type_control_system()</field>
@@ -67,7 +78,7 @@
</record>
<record model="ir.cron" id="sf_cron7">
<field name="name">同步资源库品牌</field>
<field name="name">同步静态资源库品牌</field>
<field name="model_id" ref="model_sf_machine_brand"/>
<field name="state">code</field>
<field name="code">model.sync_machine_brand()</field>
@@ -77,19 +88,8 @@
<field name="doall" eval="False"/>
</record>
<record model="ir.cron" id="sf_cron8">
<field name="name">同步表面工艺类别</field>
<field name="model_id" ref="model_sf_production_process_category"/>
<field name="state">code</field>
<field name="code">model.sync_production_process_category()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</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="name">同步静态资源库机床型号</field>
<field name="model_id" ref="model_sf_machine_tool_type"/>
<field name="state">code</field>
<field name="code">model.sync_machine_tool_type()</field>
@@ -100,7 +100,7 @@
</record>
<record model="ir.cron" id="sf_cron12">
<field name="name">同步资源库工序</field>
<field name="name">同步静态资源库工序</field>
<field name="model_id" ref="model_sf_processing_order"/>
<field name="state">code</field>
<field name="code">model.sync_processing_order()</field>
@@ -111,7 +111,7 @@
</record>
<record model="ir.cron" id="sf_cron13">
<field name="name">同步表面工艺可选参数</field>
<field name="name">同步静态表面工艺可选参数</field>
<field name="model_id" ref="model_sf_production_process_parameter"/>
<field name="state">code</field>
<field name="code">model.sync_production_process_parameter()</field>
@@ -122,7 +122,7 @@
</record>
<record model="ir.cron" id="sf_cron14">
<field name="name">同步资源库机床类型</field>
<field name="name">同步静态资源库机床类型</field>
<field name="model_id" ref="model_sf_machine_tool_category"/>
<field name="state">code</field>
<field name="code">model.sync_machine_tool_category()</field>
@@ -134,7 +134,7 @@
<record model="ir.cron" id="sf_cutting_tool_material">
<field name="name">同步刀具物料</field>
<field name="name">同步静态资源库刀具物料</field>
<field name="model_id" ref="model_sf_cutting_tool_material"/>
<field name="state">code</field>
<field name="code">model.sync_cutting_tool_material()</field>
@@ -145,7 +145,7 @@
</record>
<record model="ir.cron" id="sf_cutting_tool_type">
<field name="name">同步刀具类型</field>
<field name="name">同步静态资源库刀具类型</field>
<field name="model_id" ref="model_sf_cutting_tool_type"/>
<field name="state">code</field>
<field name="code">model.sync_tool_type()</field>
@@ -155,30 +155,8 @@
<field name="doall" eval="False"/>
</record>
<record model="ir.cron" id="sf_cutting_tool_model">
<field name="name">同步刀具型号</field>
<field name="model_id" ref="model_sf_cutting_tool_model"/>
<field name="state">code</field>
<field name="code">model.sync_tool_model()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
</record>
<record model="ir.cron" id="sf_cron15">
<field name="name">同步功能刀具型号</field>
<field name="model_id" ref="model_sf_functional_cutting_tool"/>
<field name="state">code</field>
<field name="code">model.sync_functional_cutting_tool()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
</record>
<record model="ir.cron" id="sf_cron16">
<field name="name">同步功能刀具类型</field>
<field name="name">同步静态资源库功能刀具类型</field>
<field name="model_id" ref="model_sf_functional_cutting_tool_model"/>
<field name="state">code</field>
<field name="code">model.sync_functional_cutting_tool_model()</field>
@@ -189,7 +167,7 @@
</record>
<record model="ir.cron" id="sf_fixture_material">
<field name="name">同步夹具物料</field>
<field name="name">同步静态资源库夹具物料</field>
<field name="model_id" ref="model_sf_fixture_material"/>
<field name="state">code</field>
<field name="code">model.sync_fixture_material()</field>
@@ -200,7 +178,7 @@
</record>
<record model="ir.cron" id="sf_multi_mounting_type">
<field name="name">同步联装类型</field>
<field name="name">同步静态资源库联装类型</field>
<field name="model_id" ref="model_sf_multi_mounting_type"/>
<field name="state">code</field>
<field name="code">model.sync_multi_mounting_type()</field>
@@ -211,7 +189,7 @@
</record>
<record model="ir.cron" id="sf_fixture_model">
<field name="name">同步夹具型号</field>
<field name="name">同步静态资源库夹具型号</field>
<field name="model_id" ref="model_sf_fixture_model"/>
<field name="state">code</field>
<field name="code">model.sync_fixture_model()</field>
@@ -222,7 +200,7 @@
</record>
<record model="ir.cron" id="sf_functional_fixture_type">
<field name="name">同步功能夹具类型</field>
<field name="name">同步静态资源库功能夹具类型</field>
<field name="model_id" ref="model_sf_functional_fixture_type"/>
<field name="state">code</field>
<field name="code">model.sync_functional_fixture_type()</field>
@@ -231,15 +209,4 @@
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
</record>
<record model="ir.cron" id="sf_functional_fixture">
<field name="name">同步功能夹具</field>
<field name="model_id" ref="model_sf_functional_fixture"/>
<field name="state">code</field>
<field name="code">model.sync_functional_fixture()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
</record>
</odoo>

View File

@@ -39,34 +39,23 @@ class ResConfigSettings(models.TransientModel):
_logger.info("同步资源库控制系统")
self.env['sf.machine_tool.category'].sync_all_machine_tool_category()
_logger.info("同步资源库机床类型")
# self.env['sf.production.process.parameter'].sync_all_production_process_parameter()
# _logger.info("同步表面工艺参数")
_logger.info("同步所有刀具物料...")
self.env['sf.production.process.parameter'].sync_all_production_process_parameter()
_logger.info("同步刀具物料")
self.env['sf.cutting.tool.material'].sync_all_cutting_tool_material()
_logger.info("同步所有刀具物料完成")
_logger.info("同步所有刀具类型...")
_logger.info("同步刀具类型")
self.env['sf.cutting.tool.type'].sync_all_tool_type()
_logger.info("同步所有刀具类型完成")
_logger.info("同步所有刀具型号...")
self.env['sf.cutting.tool.model'].sync_all_tool_model()
_logger.info("同步所有刀具型号完成")
_logger.info("定时同步所有功能刀具类型列表...")
_logger.info("同步功能刀具类型")
self.env['sf.functional.cutting.tool.model'].sync_all_functional_cutting_tool_model()
_logger.info("同步所有功能刀具类型完成")
# _logger.info("同步所有功能刀具列表...")
# self.env['sf.functional.cutting.tool'].sync_all_functional_cutting_tool()
# _logger.info("同步所有功能刀具列表完成")
self.env['sf.fixture.material'].sync_all_fixture_material()
_logger.info("同步夹具物料")
self.env['sf.multi_mounting.type'].sync_all_multi_mounting_type()
self.env['sf.fixture.material'].sync_all_fixture_material()
_logger.info("同步联装类型")
self.env['sf.fixture.model'].sync_all_fixture_model()
self.env['sf.multi_mounting.type'].sync_all_multi_mounting_type()
_logger.info("同步夹具型号")
self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type()
self.env['sf.fixture.model'].sync_all_fixture_model()
_logger.info("同步功能夹具类型")
self.env['sf.functional.fixture'].sync_all_functional_fixture()
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type()
_logger.info("同步资源库机床型号")
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
except Exception as e:
_logger.info("捕获错误信息:%s" % e)
raise ValidationError("数据错误导致同步失败,请联系管理员")

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['sale', 'web_widget_model_viewer'],
'depends': ['sale', 'sale_management', 'web_widget_model_viewer'],
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',

View File

@@ -82,7 +82,7 @@ class QuickEasyOrder(models.Model):
# logging.info('create-model_file:%s' % len(vals['model_file']))
obj = super(QuickEasyOrder, self).create(vals)
# self.model_coloring(obj)
self.model_coloring(obj)
self.distribute_to_factory(obj)
obj.state = '待接单'
return obj
@@ -90,14 +90,14 @@ class QuickEasyOrder(models.Model):
# 将attach的datas内容转为glb文件
def transition_glb_file(self, report_path, model_code):
shapes = read_step_file(report_path)
output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
# output_file = os.path.join('/tmp', str(model_code) + '.stl')
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
output_file = os.path.join('/tmp', str(model_code) + '.stl')
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
# 转化为glb
output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb')
# output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
# output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb')
output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
util_path = get_resource_path('sf_dlm', 'static/util')
cmd = 'python %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
os.system(cmd)
# 转base64
with open(output_glb_file, 'rb') as fileObj:
@@ -122,17 +122,17 @@ class QuickEasyOrder(models.Model):
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
logging.info("模型编码: %s" % model_code)
item.model_file = self.transition_glb_file(report_path, model_code)
# ret = self.feature_recognition(report_path, model_code)
# logging.info("自动报价返回值: %s" % ret)
# boxshape = ret['boxshape'].tolist()
# logging.info("自动报价boxshape: %s" % boxshape)
# logging.info('自动报价feature_infos:%s' % ret['feature_infos'])
# item.model_length = boxshape[0] # 长 单位mm
# item.model_width = boxshape[1] # 宽
# item.model_height = boxshape[2] # 高
# item.model_volume = boxshape[0] * boxshape[1] * boxshape[2]
# item.model_feature = json.dumps(ret['feature_infos'], ensure_ascii=False)
# self._get_price(item)
ret = self.feature_recognition(report_path, model_code)
logging.info("自动报价返回值: %s" % ret)
boxshape = ret['boxshape'].tolist()
logging.info("自动报价boxshape: %s" % boxshape)
logging.info('自动报价feature_infos:%s' % ret['feature_infos'])
item.model_length = boxshape[0] # 长 单位mm
item.model_width = boxshape[1] # 宽
item.model_height = boxshape[2] # 高
item.model_volume = boxshape[0] * boxshape[1] * boxshape[2]
item.model_feature = json.dumps(ret['feature_infos'], ensure_ascii=False)
self._get_price(item)
else:
item.model_file = False
item.model_feature = False