Merge branch 'feature/优化agv和ftp' into develop

This commit is contained in:
jinling.yang
2024-04-22 09:26:52 +08:00
10 changed files with 151 additions and 39 deletions

View File

@@ -9,16 +9,25 @@ access_sf_machine_brand_tags,sf_machine_brand_tags,model_sf_machine_brand_tags,b
access_sf_machine_brand_tags_admin,sf_machine_brand_tags_admin,model_sf_machine_brand_tags,base.group_system,1,1,1,0
access_sf_machine_control_system,sf_machine_control_system,model_sf_machine_control_system,base.group_user,1,1,1,0
access_sf_machine_control_system_admin,sf_machine_control_system_admin,model_sf_machine_control_system,base.group_system,1,1,1,0
access_sf_production_process_group_sale_director,sf_production_process_group_sale_director,model_sf_production_process,sf_base.group_sale_director,1,0,0,0
access_sf_production_process_group_sale_salemanager,sf_production_process_group_sale_salemanager,model_sf_production_process,sf_base.group_sale_salemanager,1,0,0,0
access_sf_production_process,sf_production_process,model_sf_production_process,base.group_user,1,1,1,0
access_sf_production_process_admin,sf_production_process_admin,model_sf_production_process,base.group_system,1,1,1,0
access_sf_production_materials,sf_production_materials,model_sf_production_materials,base.group_user,1,1,1,0
access_sf_production_materials_group_sale_director,sf_production_materials_group_sale_director,model_sf_production_materials,sf_base.group_sale_director,1,0,0,0
access_sf_production_materials_group_sale_salemanager,sf_production_materials_group_sale_salemanager,model_sf_production_materials,sf_base.group_sale_salemanager,1,0,0,0
access_sf_production_materials_admin,sf_production_materials_admin,model_sf_production_materials,base.group_system,1,1,1,0
access_sf_materials_model,sf_materials_model,model_sf_materials_model,base.group_user,1,1,1,0
access_sf_materials_model_admin,sf_materials_model_admin,model_sf_materials_model,base.group_system,1,1,1,0
access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,base.group_user,1,1,1,0
access_sf_supplier_sort_admin,sf_supplier_sort_admin,model_sf_supplier_sort,base.group_system,1,1,1,0
access_sf_production_process_parameter,sf_production_process_parameter,model_sf_production_process_parameter,base.group_user,1,1,1,0
access_sf_production_process_parameter_group_sale_director,sf_production_process_parameter_group_sale_director,model_sf_production_process_parameter,sf_base.group_sale_director,1,0,0,0
access_sf_production_process_parameter_group_sale_salemanager,sf_production_process_parameter_group_sale_salemanager,model_sf_production_process_parameter,sf_base.group_sale_salemanager,1,0,0,0
access_sf_production_process_parameter_group_plan_director,sf_production_process_parameter_group_plan_director,model_sf_production_process_parameter,sf_base.group_plan_director,1,0,0,0
access_sf_production_process_parameter_group_purchase_director,sf_production_process_parameter_group_purchase_director,model_sf_production_process_parameter,sf_base.group_purchase_director,1,0,0,0
access_sf_production_process_parameter_group_sale_director,sf_production_process_parameter_group_sale_director,model_sf_production_process_parameter,sf_base.group_sale_director,1,0,0,0
@@ -101,6 +110,10 @@ access_sf_production_materials_group_plan_director,sf_production_materials_group
access_sf_production_materials_group_purchase_director,sf_production_materials_group_purchase_director,model_sf_production_materials,sf_base.group_purchase_director,1,1,0,0
access_sf_production_materials_group_sale_director,sf_production_materials_group_sale_director,model_sf_production_materials,sf_base.group_sale_director,1,1,0,0
access_sf_materials_model,sf_materials_model,model_sf_materials_model,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_materials_model_group_sale_salemanager,sf_materials_model_group_sale_salemanager,model_sf_materials_model,sf_base.group_sale_salemanager,1,0,0,0
access_sf_materials_model_group_sale_director,sf_materials_model_group_sale_director,model_sf_materials_model,sf_base.group_sale_director,1,0,0,0
access_sf_materials_model_group_plan_director,sf_materials_model_group_plan_director,model_sf_materials_model,sf_base.group_plan_director,1,0,0,0
access_sf_materials_model_group_purchase_director,sf_materials_model_group_purchase_director,model_sf_materials_model,sf_base.group_purchase_director,1,0,0,0
access_sf_materials_model_group_sale_director,sf_materials_model_group_sale_director,model_sf_materials_model,sf_base.group_sale_director,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
9 access_sf_machine_brand_tags_admin sf_machine_brand_tags_admin model_sf_machine_brand_tags base.group_system 1 1 1 0
10 access_sf_machine_control_system sf_machine_control_system model_sf_machine_control_system base.group_user 1 1 1 0
11 access_sf_machine_control_system_admin sf_machine_control_system_admin model_sf_machine_control_system base.group_system 1 1 1 0
12 access_sf_production_process_group_sale_director sf_production_process_group_sale_director model_sf_production_process sf_base.group_sale_director 1 0 0 0
13 access_sf_production_process_group_sale_salemanager sf_production_process_group_sale_salemanager model_sf_production_process sf_base.group_sale_salemanager 1 0 0 0
14 access_sf_production_process sf_production_process model_sf_production_process base.group_user 1 1 1 0
15 access_sf_production_process_admin sf_production_process_admin model_sf_production_process base.group_system 1 1 1 0
16 access_sf_production_materials sf_production_materials model_sf_production_materials base.group_user 1 1 1 0
17 access_sf_production_materials_admin access_sf_production_materials_group_sale_director sf_production_materials_admin sf_production_materials_group_sale_director model_sf_production_materials base.group_system sf_base.group_sale_director 1 1 0 1 0 0
18 access_sf_production_materials_group_sale_salemanager sf_production_materials_group_sale_salemanager model_sf_production_materials sf_base.group_sale_salemanager 1 0 0 0
19 access_sf_production_materials_admin sf_production_materials_admin model_sf_production_materials base.group_system 1 1 1 0
20 access_sf_materials_model sf_materials_model model_sf_materials_model base.group_user 1 1 1 0
21 access_sf_materials_model access_sf_materials_model_admin sf_materials_model sf_materials_model_admin model_sf_materials_model base.group_user base.group_system 1 1 1 0
22 access_sf_materials_model_admin access_sf_supplier_sort sf_materials_model_admin sf_supplier_sort model_sf_materials_model model_sf_supplier_sort base.group_system base.group_user 1 1 1 0
23 access_sf_supplier_sort access_sf_supplier_sort_admin sf_supplier_sort sf_supplier_sort_admin model_sf_supplier_sort base.group_user base.group_system 1 1 1 0
24 access_sf_supplier_sort_admin access_sf_production_process_parameter sf_supplier_sort_admin sf_production_process_parameter model_sf_supplier_sort model_sf_production_process_parameter base.group_system base.group_user 1 1 1 0
25 access_sf_production_process_parameter access_sf_production_process_parameter_group_sale_director sf_production_process_parameter sf_production_process_parameter_group_sale_director model_sf_production_process_parameter base.group_user sf_base.group_sale_director 1 1 0 1 0 0
26 access_sf_production_process_parameter_group_plan_director access_sf_production_process_parameter_group_sale_salemanager sf_production_process_parameter_group_plan_director sf_production_process_parameter_group_sale_salemanager model_sf_production_process_parameter sf_base.group_plan_director sf_base.group_sale_salemanager 1 0 0 0
27 access_sf_production_process_parameter_group_plan_director sf_production_process_parameter_group_plan_director model_sf_production_process_parameter sf_base.group_plan_director 1 0 0 0
28 access_sf_production_process_parameter_group_purchase_director sf_production_process_parameter_group_purchase_director model_sf_production_process_parameter sf_base.group_purchase_director 1 0 0 0
29 access_sf_production_process_parameter_group_sale_director sf_production_process_parameter_group_sale_director model_sf_production_process_parameter sf_base.group_sale_director 1 0 0 0
30 access_sf_production_process_parameter_admin sf_production_process_parameter_admin model_sf_production_process_parameter base.group_system 1 1 1 0
31 access_sf_production_process_parameter_group_purchase_director access_sf_production_process_category sf_production_process_parameter_group_purchase_director sf_production_process_category model_sf_production_process_parameter model_sf_production_process_category sf_base.group_purchase_director base.group_user 1 0 1 0 1 0
32 access_sf_production_process_parameter_group_sale_director access_sf_production_process_category_admin sf_production_process_parameter_group_sale_director sf_production_process_category_admin model_sf_production_process_parameter model_sf_production_process_category sf_base.group_sale_director base.group_system 1 0 1 0 1 0
33 access_sf_production_process_parameter_admin access_sf_machine_tool_category sf_production_process_parameter_admin sf_machine_tool_category model_sf_production_process_parameter model_sf_machine_tool_category base.group_system base.group_user 1 1 1 0
110 access_sf_materials_model access_sf_materials_model_group_plan_director sf_materials_model sf_materials_model_group_plan_director model_sf_materials_model sf_base.group_sf_mrp_user sf_base.group_plan_director 1 0 0 0
111 access_sf_materials_model_group_plan_director access_sf_materials_model_group_purchase_director sf_materials_model_group_plan_director sf_materials_model_group_purchase_director model_sf_materials_model sf_base.group_plan_director sf_base.group_purchase_director 1 0 0 0
112 access_sf_materials_model_group_purchase_director access_sf_materials_model_group_sale_director sf_materials_model_group_purchase_director sf_materials_model_group_sale_director model_sf_materials_model sf_base.group_purchase_director sf_base.group_sale_director 1 0 0 0
113 access_sf_supplier_sort sf_supplier_sort model_sf_supplier_sort sf_base.group_sf_mrp_user 1 0 0 0
114 access_sf_production_process_parameter sf_production_process_parameter model_sf_production_process_parameter sf_base.group_sf_mrp_user 1 0 0 0
115 access_sf_production_process_category sf_production_process_category model_sf_production_process_category sf_base.group_sf_mrp_user 1 0 0 0
116 access_sf_machine_tool_category sf_machine_tool_category model_sf_machine_tool_category sf_base.group_sf_mrp_user 1 0 0 0
117 access_sf_materials_model_group_sale_director access_sf_cutting_tool_material_group_purchase_director sf_materials_model_group_sale_director sf_cutting_tool_material_group_purchase_director model_sf_materials_model model_sf_cutting_tool_material sf_base.group_sale_director sf_base.group_purchase_director 1 0 0 1 0
118 access_sf_supplier_sort access_sf_cutting_tool_material_group_sale_director sf_supplier_sort sf_cutting_tool_material_group_sale_director model_sf_supplier_sort model_sf_cutting_tool_material sf_base.group_sf_mrp_user sf_base.group_sale_director 1 0 0 1 0
119 access_sf_production_process_parameter access_sf_cutting_tool_material_group_plan_director sf_production_process_parameter sf_cutting_tool_material_group_plan_director model_sf_production_process_parameter model_sf_cutting_tool_material sf_base.group_sf_mrp_user sf_base.group_plan_director 1 0 0 1 0

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import logging
import json
from datetime import datetime
from odoo import http
from odoo.http import request
@@ -438,6 +439,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('wd.production_id:%s' % wd.production_id.name)
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已上产线'})
wd.write({'production_line_state': '已上产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
@@ -471,7 +473,21 @@ class Manufacturing_Connect(http.Controller):
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
logging.info('wd.production_id:%s' % wd.production_id.name)
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
workpiece_delivery_off=request.env['sf.workpiece.delivery'].create({
'production_id': wd.production_id.id,
'feeder_station_start': ret['DeviceId'],
'feeder_station_destination': '',
'workorder_id': workpiece_delivery.workorder_id,
'workpiece_code': workpiece_delivery.workpiece_code,
'production_line_id': workpiece_delivery.production_line_id,
'task_delivery_time': datetime.now(),
'production_line_state': '已下产线'
})
wd.production_id.write({'production_line_state': '已下产线'})
logging.info('开始向agv下发下产线任务')
workpiece_delivery_off._delivery_avg()
logging.info('agv下发下产线任务已配送')
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:

View File

@@ -54,8 +54,9 @@ class MrpProduction(models.Model):
glb_file = fields.Binary("glb模型文件")
production_line_id = fields.Many2one('sf.production.line', string='生产线')
plan_start_processing_time = fields.Datetime('计划开始加工时间')
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='/下产线', default='待上产线')
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线')
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@@ -156,6 +157,7 @@ class MrpProduction(models.Model):
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
'order_no': cnc.origin,
'quick_order_no': quick_order.name if quick_order else False,
'model_order_no': cnc.product_id.default_code,
'user': cnc.env.user.name,
'programme_way': programme_way,

View File

@@ -402,16 +402,19 @@ class ResMrpWorkOrder(models.Model):
# if not item.workpiece_code:
# raise UserError('请对【同运工件】进行扫描')
else:
if item.status == '下发':
return {
'name': _('确认'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'sf.workpiece.delivery.wizard',
'target': 'new',
'context': {
'default_workorder_id': self.id,
}}
if self.cnc_program_down_state == '下发':
if item.status == '待下发':
return {
'name': _('确认'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'sf.workpiece.delivery.wizard',
'target': 'new',
'context': {
'default_workorder_id': self.id,
}}
else:
raise UserError(_("该制造订单还未下发CNC程序单无法进行工件配送"))
# 拼接工单对象属性值
def json_workorder_str(self, k, production, route):
@@ -815,7 +818,7 @@ class ResMrpWorkOrder(models.Model):
production_no_ftp = reportpath.split('/')
production_no = workorder.production_id.name.replace('/', '_')
# ftp地址
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no_ftp[1], 'detection')
remotepath = os.path.join('/NC', production_no_ftp[1], 'detection')
logging.info('ftp地址:%s' % remotepath)
if reportpath.find(production_no) != -1:
# 服务器内临时地址
@@ -933,8 +936,8 @@ class CNCprocessing(models.Model):
# 将FTP的nc文件下载到临时目录
def download_file_tmp(self, production_no, processing_panel):
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no, 'return', processing_panel)
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
serverdir = os.pat.join('/tmp', production_no, 'return', processing_panel)
ftp_resconfig = self.env['res.config.settings'].get_values()
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
ftp_resconfig['ftp_password'])
@@ -1119,26 +1122,39 @@ class WorkPieceDelivery(models.Model):
status = fields.Selection(
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
default='待下发')
production_line_state = fields.Selection(
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线')
cnc_program_down_state = fields.Selection([('待下发', '待下发'), ('已下发', '已下发')],
string='CNC程序下发状态', default='待下发')
# 工件配送
def button_delivery(self):
if self.status == '待下发':
return {
'name': _('确认'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'sf.workpiece.delivery.wizard',
'target': 'new',
'context': {
'default_delivery_id': self.id,
}}
if self.cnc_program_down_state == '待下发':
if self.status == '待下发':
return {
'name': _('确认'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'sf.workpiece.delivery.wizard',
'target': 'new',
'context': {
'default_delivery_id': self.id,
}}
else:
raise UserError('状态为【待下发】的工件记录可进行配送')
else:
raise UserError('状态为【待下发】的工件记录可进行配送')
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
# 配送至avg小车
def _delivery_avg(self):
config = self.env['res.config.settings'].get_values()
agv_site = self.env['res.agv.site'].search([])
site_production_line = False
if self.production_line_state == '待上产线':
site_production_line = [('production_line_status', '=', '已上产线')]
elif self.production_line_state == '已下产线':
site_production_line = [('production_line_status', '=', '已下产线')]
agv_site = self.env['res.agv.site'].search(site_production_line, order="number asc")
positionCode_Arr = []
if agv_site:
for item in agv_site:
@@ -1147,14 +1163,16 @@ class WorkPieceDelivery(models.Model):
'code': item.type
})
res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
'taskTyp': config['task_type_no'], 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
'positionCodePath': positionCode_Arr,
'podCode': '',
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
'data': ''}
try:
config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
logging.info('AGV请求路径:%s' % config['agv_rcs_url'])
logging.info('AGV-json:%s' % res)
headers = {'Content-Type': 'application/json'}
ret = requests.post((config['agv_rcs_url']), json=res, headers=headers)
ret = ret.json()
@@ -1168,7 +1186,7 @@ class WorkPieceDelivery(models.Model):
logging.info('config-e:%s' % e)
raise UserError("工件配送请求agv失败")
@api.depends('production_id.production_line_id')
@api.onchange('production_id.production_line_id')
def _compute_production_line_id(self):
if self.production_id.production_line_id:
self.production_line_id = self.production_id.production_line_id.id

View File

@@ -425,6 +425,7 @@
<field name="workpiece_code"/>
<field name="feeder_station_start" force_save="1"/>
<field name="feeder_station_destination" force_save="1"/>
<field name="cnc_program_down_state" readonly="1"/>
<field name="production_line_id"/>
<field name="task_delivery_time" readonly="1"/>
<field name="task_completion_time" readonly="1"/>
@@ -567,6 +568,7 @@
<field name="production_line_id"/>
<field name="feeder_station_start"/>
<field name="feeder_station_destination"/>
<field name="cnc_program_down_state"/>
<field name="task_delivery_time"/>
<field name="task_completion_time"/>
<field name="delivery_duration" widget="float_time"/>
@@ -591,6 +593,9 @@
<searchpanel>
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
<field name="status" icon="fa-building" enable_counters="1"/>
<field name="production_line_state" icon="fa-building" enable_counters="1"/>
<field name="cnc_program_down_state" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>

View File

@@ -40,19 +40,13 @@ class FtpController():
logging.info('目录:%s' % target_dir)
target_dir1 = target_dir.split('/')
logging.info('目录1:%s' % target_dir1[1])
self.ftp.cwd(target_dir1[1])
self.ftp.cwd(target_dir1[1]) # 切换工作路径
logging.info('目录2:%s' % target_dir1[2])
self.ftp.cwd(target_dir1[2])
self.ftp.cwd(target_dir1[2]) # 切换工作路径
logging.info('目录3:%s' % target_dir1[3])
self.ftp.cwd(target_dir1[3])
self.ftp.cwd(target_dir1[3]) # 切换工作路径
logging.info('目录4:%s' % target_dir1[4])
self.ftp.cwd(target_dir1[4])
logging.info('目录5:%s' % target_dir1[5])
self.ftp.cwd(target_dir1[5])
logging.info('目录6:%s' % target_dir1[6])
self.ftp.cwd(target_dir1[6])
logging.info('目录7:%s' % target_dir1[7])
self.ftp.cwd(target_dir1[7])
self.ftp.cwd(target_dir1[4]) # 切换工作路径
remotenames = self.ftp.nlst()
logging.info('FTP目录文件:%s' % remotenames)
for file in remotenames:

View File

@@ -140,5 +140,20 @@ class ResAgvSite(models.Model):
_name = 'res.agv.site'
_description = 'agv站点'
number = fields.Integer('编号')
type = fields.Selection([('00', '位置编号'), ('01', '库区编号'), ('02', '货架编号')], '类型')
content = fields.Char('内容')
site_prop = fields.Selection([('上产线', '上产线'), ('下产线', '下产线')], '属性')
state_status = fields.Selection([('占用', '占用'), ('空闲', '空闲')], '状态')
# remark = fields.Char
active = fields.Boolean('有效', default=True)
# @api.model
# def create(self, vals):
# if vals.get('number', 'new') == 'new':
# vals['number'] = self.env['ir.sequence'].next_by_code('res.agv.site') or '/'
# return super(ResAgvSite, self).create(vals)
def unlink(self):
for item in self:
item.active == True

View File

@@ -2375,6 +2375,7 @@ class CuttingToolBasicParameters(models.Model):
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
logging.info(result)
if result['status'] == 1:
if 'basic_parameters_integral_tool' in result['cutting_tool_basic_parameters_all_list']:
if result['cutting_tool_basic_parameters_all_list']['basic_parameters_integral_tool']:

View File

@@ -6,8 +6,10 @@
<field name="model">res.agv.site</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="number"/>
<field name="type"/>
<field name="content"/>
<field name="state_status"/>
</tree>
</field>
</record>

View File

@@ -1,12 +1,14 @@
import logging
import base64
import hashlib
import requests
import os
from datetime import datetime
from stl import mesh
# from OCC.Core.GProp import GProp_GProps
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
from odoo.addons.sf_base.commons.common import Common
from odoo import models, fields, api
from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError
@@ -79,6 +81,8 @@ class QuickEasyOrder(models.Model):
report_path = attachment._full_path(attachment.store_fname)
vals['model_file'] = self.transition_glb_file(report_path, model_code)
obj = super(QuickEasyOrder, self).create(vals)
logging.info('---------向cloud生成模型库记录-------')
self.model_coloring(obj)
logging.info('---------开始派单到工厂-------')
self.distribute_to_factory(obj)
obj.state = '待接单'
@@ -262,3 +266,45 @@ class QuickEasyOrder(models.Model):
except Exception as e:
# self.cr.rollback()
return UserError('工厂创建销售订单和产品失败,请联系管理员')
# 模型上色
def model_coloring(self, order):
url = '/api/library_of_models/create'
config = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
logging.info('order: %s' % order.name)
if order:
attachment = order.upload_model_file[0]
base64_data = base64.b64encode(attachment.datas)
base64_datas = base64_data.decode('utf-8')
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
logging.info('model_file-size: %s' % len(order.model_file))
logging.info('attachment.datas-size: %s' % len(attachment.datas))
vals = {
'programme_way': 'manual operation',
'model_code': model_code,
'model_data': base64.b64decode(attachment.datas),
'model_color_data': '',
'model_name': attachment.name,
'model_long': order.model_length,
'model_width': order.model_width,
'model_height': order.model_height,
'model_volume': order.model_volume,
'color_model_path': '/tmp/' + str(model_code) + ".step",
'model_order_no': order.name,
'remark': '订单号:%s 客户:%s' % (order.name, order.customer_id.name)
}
try:
ret = requests.post((config['sf_url'] + url), json={}, data=vals, headers=config_header,
timeout=60)
ret = ret.json()
# result = json.loads(ret['result'])
if ret['status'] == 1:
self.model_color_state = 'success'
else:
self.model_color_state = 'fail'
raise UserError(ret['message'])
except Exception as e:
self.model_color_state = 'fail'
raise UserError("模型上色失败")