Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/bug修复

This commit is contained in:
jinling.yang
2023-09-18 17:40:30 +08:00
14 changed files with 431 additions and 674 deletions

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