Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/刀具产品调取Cloud刀具标准库(10.11)
# Conflicts: # sf_sale/models/quick_easy_order.py
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
from odoo import fields, models, api
|
from odoo import fields, models, api
|
||||||
#from quatotion import readSql, feature_recognize, auto_quatotion
|
from quatotion import readSql, feature_recognize, auto_quatotion
|
||||||
|
|
||||||
__author__ = 'jinling.yang'
|
__author__ = 'jinling.yang'
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@@ -24,14 +24,14 @@ class AutoQuatotion(models.Model):
|
|||||||
def get_process_time_db_path(self):
|
def get_process_time_db_path(self):
|
||||||
return get_resource_path('sf_sale', 'models', 'process_time.db')
|
return get_resource_path('sf_sale', 'models', 'process_time.db')
|
||||||
|
|
||||||
# def get_auto_quatotion(self, stp_url, feature_full_path, process_time_db_path, model_code):
|
def get_auto_quatotion(self, stp_url, feature_full_path, process_time_db_path, model_code):
|
||||||
# '''
|
'''
|
||||||
# 通过打包好的.so库,
|
通过打包好的.so库,
|
||||||
# 以调用autoQuatotion库中Quatotion类,
|
以调用autoQuatotion库中Quatotion类,
|
||||||
# 初始化后调用类的analyseShape方法对模型文件进行价格预测
|
初始化后调用类的analyseShape方法对模型文件进行价格预测
|
||||||
# '''
|
'''
|
||||||
# # 初始化自动报价类(输入特征数据库和加工时间数据库)
|
# 初始化自动报价类(输入特征数据库和加工时间数据库)
|
||||||
# reader = auto_quatotion.Quatotion(feature_full_path, process_time_db_path)
|
reader = auto_quatotion.Quatotion(feature_full_path, process_time_db_path)
|
||||||
# # 获取价格、加工时间、尺寸、XYZ、翻面次数
|
# 获取价格、加工时间、尺寸、XYZ、翻面次数
|
||||||
# feature_info = reader.analyseShape(stp_url, InfoJson={})
|
feature_info = reader.analyseShape(stp_url, InfoJson={})
|
||||||
# return feature_info
|
return feature_info
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
|
|
||||||
obj = super(QuickEasyOrder, self).create(vals)
|
obj = super(QuickEasyOrder, self).create(vals)
|
||||||
# self.model_coloring(obj)
|
# self.model_coloring(obj)
|
||||||
|
logging.info('---------开始派单到工厂-------')
|
||||||
self.distribute_to_factory(obj)
|
self.distribute_to_factory(obj)
|
||||||
obj.state = '待接单'
|
obj.state = '待接单'
|
||||||
return obj
|
return obj
|
||||||
@@ -90,13 +91,9 @@ class QuickEasyOrder(models.Model):
|
|||||||
# 将attach的datas内容转为glb文件
|
# 将attach的datas内容转为glb文件
|
||||||
def transition_glb_file(self, report_path, model_code):
|
def transition_glb_file(self, report_path, model_code):
|
||||||
shapes = read_step_file(report_path)
|
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('/tmp', str(model_code) + '.stl')
|
||||||
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||||
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
|
|
||||||
output_file = os.path.join('/tmp', str(model_code) + '.stl')
|
|
||||||
# 转化为glb
|
# 转化为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('/tmp', str(model_code) + '.glb')
|
||||||
util_path = get_resource_path('sf_dlm', 'static/util')
|
util_path = get_resource_path('sf_dlm', 'static/util')
|
||||||
cmd = 'python3 %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)
|
||||||
@@ -124,17 +121,17 @@ class QuickEasyOrder(models.Model):
|
|||||||
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
logging.info("模型编码: %s" % model_code)
|
logging.info("模型编码: %s" % model_code)
|
||||||
item.model_file = self.transition_glb_file(report_path, model_code)
|
item.model_file = self.transition_glb_file(report_path, model_code)
|
||||||
# ret = self.feature_recognition(report_path, model_code)
|
ret = self.feature_recognition(report_path, model_code)
|
||||||
# logging.info("自动报价返回值: %s" % ret)
|
logging.info("自动报价返回值: %s" % ret)
|
||||||
# boxshape = ret['boxshape'].tolist()
|
boxshape = ret['boxshape'].tolist()
|
||||||
# logging.info("自动报价boxshape: %s" % boxshape)
|
logging.info("自动报价boxshape: %s" % boxshape)
|
||||||
# logging.info('自动报价feature_infos:%s' % ret['feature_infos'])
|
logging.info('自动报价feature_infos:%s' % ret['feature_infos'])
|
||||||
# item.model_length = boxshape[0] # 长 单位mm
|
item.model_length = boxshape[0] # 长 单位mm
|
||||||
# item.model_width = boxshape[1] # 宽
|
item.model_width = boxshape[1] # 宽
|
||||||
# item.model_height = boxshape[2] # 高
|
item.model_height = boxshape[2] # 高
|
||||||
# item.model_volume = boxshape[0] * boxshape[1] * boxshape[2]
|
item.model_volume = boxshape[0] * boxshape[1] * boxshape[2]
|
||||||
# item.model_feature = json.dumps(ret['feature_infos'], ensure_ascii=False)
|
item.model_feature = json.dumps(ret['feature_infos'], ensure_ascii=False)
|
||||||
# self._get_price(item)
|
self._get_price(item)
|
||||||
else:
|
else:
|
||||||
item.model_file = False
|
item.model_file = False
|
||||||
item.model_feature = False
|
item.model_feature = False
|
||||||
@@ -149,6 +146,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
logging.info('---------派单到工厂-------')
|
||||||
res = {'bfm_process_order_list': []}
|
res = {'bfm_process_order_list': []}
|
||||||
for item in obj:
|
for item in obj:
|
||||||
attachment = item.upload_model_file[0]
|
attachment = item.upload_model_file[0]
|
||||||
@@ -189,6 +187,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
i = 1
|
i = 1
|
||||||
# 给sale_order的default_code字段赋值
|
# 给sale_order的default_code字段赋值
|
||||||
aa = self.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
aa = self.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
||||||
|
logging.info('---------aa------- %s' % aa.name)
|
||||||
aa.default_code = obj.name
|
aa.default_code = obj.name
|
||||||
for item in res['bfm_process_order_list']:
|
for item in res['bfm_process_order_list']:
|
||||||
product = self.env['product.template'].sudo().product_create(product_id, item, order_id,
|
product = self.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user