Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化

# Conflicts:
#	zpl_print/models/common.py
This commit is contained in:
mgw
2024-03-14 14:24:26 +08:00
38 changed files with 1334 additions and 496 deletions

View File

@@ -1 +1,2 @@
from . import controllers
from . import workpiece

View File

@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
import logging
import json
from odoo import http
from odoo.http import request
class Workpiece(http.Controller):
@http.route('/agvApi/backfeed', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def backfeed(self, **kw):
"""
agv小车反馈工单(工件)结果
:param kw:
:return:
"""
logging.info('backfeed:%s' % kw)
try:
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('backfeed-ret:%s' % ret)
if 'reqCode' in ret:
if 'method' in ret:
if ret['method'] == 'end':
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('production_id.name', '=', ret['reqCode'])])
if workpiece_delivery:
workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'}
else:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '未传method字段'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传reqCode字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('backfeed error:%s' % e)
return json.JSONEncoder().encode(res)

View File

@@ -134,6 +134,7 @@ class ResMrpWorkOrder(models.Model):
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
is_delivery = fields.Boolean('是否配送完成', default=False)
rfid_code = fields.Char('RFID码')
rfid_code_old = fields.Char('RFID码(已解除)')
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
string='生产线', store=True)
production_line_state = fields.Selection(related='production_id.production_line_state',
@@ -235,7 +236,16 @@ class ResMrpWorkOrder(models.Model):
# if not item.workpiece_code:
# raise UserError('请对【同运工件】进行扫描')
else:
item.write({'task_delivery_time': fields.Datetime.now(), 'status': '配送'})
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,
}}
# 拼接工单对象属性值
def json_workorder_str(self, k, production, route):
@@ -624,6 +634,7 @@ class ResMrpWorkOrder(models.Model):
is_production_id = False
if is_production_id == True and self.name == '解除装夹':
for workorder in self.production_id.workorder_ids:
workorder.rfid_code_old = workorder.rfid_code
workorder.rfid_code = None
for move_raw_id in self.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty
@@ -897,7 +908,25 @@ class WorkPieceDelivery(models.Model):
# 配送至avg小车
def _delivery_avg(self):
self.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': '', 'positionCodePath': [], 'podCode': '',
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
'data': ''}
config = self.env['res.config.settings'].get_values()
try:
logging.info('config-AGV请求路径:%s' % config['agv_rcms_url'])
logging.info('config-json:%s' % res)
ret = requests.post((config['agv_rcms_url']), json=res)
ret = ret.json()
logging.info('config-ret:%s' % ret)
if ret['code'] == 0:
if self.production_id.name == ret['reqCode']:
self.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
else:
raise UserError(ret['message'])
except Exception as e:
logging.info('config-e:%s' % e)
raise UserError("工件配送请求agv失败")
@api.depends('production_id.production_line_id')
def _compute_production_line_id(self):

View File

@@ -6,6 +6,8 @@ import os
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
@@ -68,7 +70,8 @@ class ResProductMo(models.Model):
cutting_tool_shank_length = fields.Float('柄部长度(mm)', digits=(6, 1))
cutting_tool_blade_length = fields.Float('刃部长度(mm)')
cutting_tool_blade_number = fields.Selection(
[('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')], '刃数(个)')
[('0', '0'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')],
string='刃数(个)', default='0')
# 整体式刀具新增字段
cutting_tool_neck_length = fields.Float('颈部长度(mm)', digits=(6, 1))
cutting_tool_neck_diameter = fields.Float('颈部直径(mm)', digits=(6, 1))
@@ -101,6 +104,10 @@ class ResProductMo(models.Model):
compaction_way_id = fields.Many2one('maintenance.equipment.image',
'压紧方式', domain=[('type', '=', '压紧方式')])
@api.onchange('cutting_tool_model_id')
def _onchange_cutting_tool_model_id(self):
self.specification_id = False
@api.onchange('cutting_tool_material_id')
def _onchange_cutting_tool_material_id(self):
for item in self:
@@ -190,20 +197,24 @@ class ResProductMo(models.Model):
self.cutting_tool_blade_number = self.specification_id.blade_number
self.cutting_tool_blade_type = self.cutting_tool_model_id.blade_type
self.cutting_tool_shank_diameter = self.specification_id.handle_diameter
self.cutting_tool_shank_length = self.specification_id.handle_length
self.cutting_tool_neck_length = self.specification_id.neck_length
self.cutting_tool_neck_diameter = self.specification_id.neck_diameter
self.cutting_tool_blade_tip_diameter = self.specification_id.blade_tip_diameter
self.cutting_tool_blade_tip_taper = self.specification_id.blade_tip_taper
self.cutting_tool_blade_helix_angle = self.specification_id.blade_helix_angle
self.cutting_tool_blade_tip_working_size = self.specification_id.blade_tip_working_size
self.cutting_tool_pitch = self.specification_id.pitch
self.cutting_tool_blade_width = self.specification_id.blade_width
self.cutting_tool_blade_depth = self.specification_id.blade_depth
self.cutting_tool_cut_depth = self.specification_id.cutting_depth
self.cutting_tool_cut_depth_max = self.specification_id.cut_depth_max
self.cutting_speed_ids = self.cutting_tool_model_id.cutting_speed_ids
self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.filtered(
lambda r: int(r.blade_diameter) == int(self.specification_id.blade_diameter))
elif self.cutting_tool_type == '夹头':
self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter
self.cutting_tool_clamping_diameter_min = self.specification_id.max_clamping_diameter
self.cutting_tool_clamping_way = self.specification_id.clamping_mode
self.cutting_tool_clamping_diameter_max = self.specification_id.max_clamping_diameter
self.cutting_tool_taper = self.specification_id.taper
self.cutting_tool_top_diameter = self.specification_id.top_diameter
self.cutting_tool_outer_diameter = self.specification_id.outer_diameter
self.cutting_tool_inner_diameter = self.specification_id.inner_diameter
@@ -241,6 +252,7 @@ class ResProductMo(models.Model):
self.cutting_speed_ids = self.cutting_tool_model_id.cutting_speed_ids
self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids
elif self.cutting_tool_type in ('刀盘', '刀杆'):
self.cutting_tool_blade_diameter = self.specification_id.blade_diameter
self.cutting_tool_total_length = self.specification_id.total_length
self.tool_length = self.specification_id.length
self.tool_thickness = self.specification_id.thickness
@@ -271,14 +283,19 @@ class ResProductMo(models.Model):
self.cutting_tool_cutter_head_diameter = self.specification_id.cutter_head_diameter
self.cutting_tool_interface_diameter = self.specification_id.interface_diameter
else:
self.cutting_tool_cutter_arbor_diameter = self.specification_id.cutter_arbor_diameter
self.cutting_tool_knife_head_height = self.specification_id.knife_head_height
self.cutting_tool_knife_head_width = self.specification_id.knife_head_width
self.cutting_tool_knife_head_length = self.specification_id.knife_head_length
self.cutting_tool_tool_shim = self.specification_id.tool_shim
self.cutting_tool_cotter_pin = self.specification_id.cotter_pin
self.cutting_tool_pressing_plate = self.specification_id.pressing_plate
self.cutting_tool_min_machining_aperture = self.specification_id.min_machining_aperture
self.cutting_tool_rear_angle = self.specification_id.relief_angle
elif self.cutting_tool_type == '刀柄':
self.cutting_tool_total_length = self.specification_id.total_length
self.cutting_tool_shank_diameter = self.specification_id.shank_diameter
self.cutting_tool_shank_length = self.specification_id.shank_length
self.cutting_tool_speed_max = self.specification_id.max_rotate_speed
self.cutting_tool_change_time = self.specification_id.tool_changing_time
self.cutting_tool_total_length = self.specification_id.total_length
@@ -295,6 +312,8 @@ class ResProductMo(models.Model):
self.cutting_tool_chuck_id = self.specification_id.chuck_id.id
self.cutting_tool_jump_accuracy = self.specification_id.diameter_slip_accuracy
self.cutting_tool_taper_shank_model = self.specification_id.taper_shank_model
self.cutting_tool_cooling_type = self.specification_id.cooling_model
self.cutting_tool_clamping_way = self.specification_id.clamping_mode
self.suitable_machining_method_ids = [(6, 0, [])] if not \
self.cutting_tool_model_id.suitable_machining_method_ids \
else [(6, 0, self.cutting_tool_model_id.suitable_machining_method_ids.ids)]
@@ -350,30 +369,30 @@ class ResProductMo(models.Model):
self.cutting_speed_ids = False
self.feed_per_tooth_ids = False
@api.constrains('fit_blade_shape_id', 'suitable_machining_method_ids', 'blade_tip_characteristics_id',
'handle_type_id', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_id')
def _check_cutting_tool_ability(self):
if self.cutting_tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
if self.cutting_tool_type in ['刀片', '刀杆', '刀盘']:
if not self.fit_blade_shape_id:
raise ValidationError("请选择适配刀片形状")
if self.cutting_tool_type in ['刀杆', '刀盘']:
if not self.compaction_way_id:
raise ValidationError("请选择压紧方式")
if self.cutting_tool_type == '刀片':
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却方式")
elif self.cutting_tool_type == '整体式刀具':
if not self.handle_type_id:
raise ValidationError("请选择柄部类型")
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却方式")
if not self.suitable_machining_method_ids:
raise ValidationError("请选择适合加工方式")
if not self.blade_tip_characteristics_id:
raise ValidationError("请选择刀尖特征")
if not self.cutting_direction_ids:
raise ValidationError("请选择走刀方向")
# @api.constrains('fit_blade_shape_id', 'suitable_machining_method_ids', 'blade_tip_characteristics_id',
# 'handle_type_id', 'cutting_direction_ids', 'suitable_coolant_ids', 'compaction_way_id')
# def _check_cutting_tool_ability(self):
# if self.cutting_tool_type in ['整体式刀具', '刀片', '刀杆', '刀盘']:
# if self.cutting_tool_type in ['刀片', '刀杆', '刀盘']:
# if not self.fit_blade_shape_id:
# raise ValidationError("请选择适配刀片形状")
# if self.cutting_tool_type in ['刀杆', '刀盘']:
# if not self.compaction_way_id:
# raise ValidationError("请选择压紧方式")
# if self.cutting_tool_type == '刀片':
# if not self.suitable_coolant_ids:
# raise ValidationError("请选择适合冷却方式")
# elif self.cutting_tool_type == '整体式刀具':
# if not self.handle_type_id:
# raise ValidationError("请选择柄部类型")
# if not self.suitable_coolant_ids:
# raise ValidationError("请选择适合冷却方式")
# if not self.suitable_machining_method_ids:
# raise ValidationError("请选择适合加工方式")
# if not self.blade_tip_characteristics_id:
# raise ValidationError("请选择刀尖特征")
# if not self.cutting_direction_ids:
# raise ValidationError("请选择走刀方向")
cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc')
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')

View File

@@ -184,7 +184,9 @@
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_type_id"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" force_save="1" readonly="1" class="customRFID"/>
<field name="rfid_code" force_save="1" readonly="1" class="customRFID"
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
<script src="/sf_manufacturing/static/src/js/customRFID.js"></script>
</group>
<!-- <group>-->
@@ -540,7 +542,7 @@
<field name="arch" type="xml">
<tree string="工件配送">
<header>
<button name="button_delivery" type="object" string="配送"/>
<button name="button_delivery" type="object" string="配送" class="oe_highlight"/>
</header>
<field name="status" widget="badge"
decoration-success="status == '已配送'"

View File

@@ -6,6 +6,8 @@
<field name="arch" type="xml">
<form>
<field name="delivery_id" invisible="True"/>
<field name="workorder_id" invisible="True"/>
<div>
是否确定配送?
</div>

View File

@@ -10,7 +10,11 @@ class WorkpieceDeliveryWizard(models.TransientModel):
_description = '工件配送'
delivery_id = fields.Many2one('sf.workpiece.delivery', string='配送')
workorder_id = fields.Many2one('mrp.workorder', string='工单')
def confirm(self):
self.delivery_id._delivery_avg()
if self.workorder_id:
self.workorder_id.workpiece_delivery_ids._delivery_avg()
else:
self.delivery_id._delivery_avg()