Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/新增机台日计划,工件预调(前置三元检测),NC程序下载接口

# Conflicts:
#	sf_manufacturing/controllers/controllers.py
This commit is contained in:
jinling.yang
2024-01-22 15:35:13 +08:00
32 changed files with 940 additions and 306 deletions

View File

@@ -115,33 +115,103 @@ class Manufacturing_Connect(http.Controller):
logging.info('get_qcCheck error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_qcCheck(self, **kw):
def button_Work_START(self, **kw):
"""
件预调(前置三元检测)
1、前置三元检测在产线外三元检测设备把测量信息上传给MES
MES生成检测定位数据。中控系统传递RFID编号给MES获取测量偏置结果。来源为三元检测工单上的字段
单任务开始
:param kw:
:return:
"""
logging.info('get_qcCheck:%s' % kw)
logging.info('button_Work_START:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
ret = json.loads(ret['result'])
logging.info('RfidCode:%s' % ret)
workorder = request.env['mrp.workorder'].sudo().search([('routing_type', '=', '前置三元定位检测')])
if workorder:
for item in workorder:
res['Datas'].append({
'XOffset': item.production_id.name,
'YOffset': item.RfidCode,
'ZOffet': item.name,
'COffset': 1
})
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
workorder.button_start()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_qcCheck error:%s' % e)
logging.info('button_Work_START error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/FeedBackEnd', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def button_Work_End(self, **kw):
"""
工单任务结束
:param kw:
:return:
"""
logging.info('button_Work_End:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
workorder.button_finish()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('button_Work_End error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def Workorder_QcCheck(self, **kw):
"""
零件质检
:param kw:
:return:
"""
logging.info('Workorder_QcCheck:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
if not ret['Quality']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传检测结果'}
return json.JSONEncoder().encode(res)
if not ret['ReportPaht']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传检查报告文件(地址)'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('Workorder_QcCheck error:%s' % e)
return json.JSONEncoder().encode(res)

View File

@@ -450,10 +450,10 @@ class MrpProduction(models.Model):
for route in routingworkcenter:
if route.routing_type == '后置三元质量检测':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route)
)
# if route.routing_type == '后置三元质量检测':
# workorders_values.append(
# self.env['mrp.workorder'].json_workorder_str1(k, production, route)
# )
if route.routing_type == 'CNC加工':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route))

View File

@@ -11,7 +11,7 @@ class ResMrpRoutingWorkcenter(models.Model):
('装夹预调', '装夹预调'),
# ('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
# ('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('切割', '切割'),
('表面工艺', '表面工艺')

View File

@@ -35,7 +35,7 @@ class ResMrpWorkOrder(models.Model):
('装夹预调', '装夹预调'),
# ('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
# ('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
@@ -216,9 +216,9 @@ class ResMrpWorkOrder(models.Model):
elif route.routing_type == 'CNC加工':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', 'CNC加工')]).time_cycle
elif route.routing_type == '后置三元质量检测':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '后置三元质量检测')]).time_cycle
# elif route.routing_type == '后置三元质量检测':
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
# [('name', '=', '后置三元质量检测')]).time_cycle
elif route.routing_type == '解除装夹':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '解除装夹')]).time_cycle
@@ -597,6 +597,7 @@ class CNCprocessing(models.Model):
cnc_id = fields.Many2one('ir.attachment')
sequence_number = fields.Char('序号')
program_name = fields.Char('程序名')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
cutting_tool_name = fields.Char('刀具名称')
cutting_tool_no = fields.Char('刀号')
processing_type = fields.Char('加工类型')

View File

@@ -870,21 +870,9 @@ class SfMaintenanceEquipmentTool(models.Model):
_description = '机床刀位'
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
product_template_id = fields.Many2one('product.template', string='功能刀具名称',
domain="[('categ_type', '=', '刀具')]")
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
categ_type = fields.Char(string='功能刀具类型')
diameter = fields.Char('直径')
precision = fields.Char('\\')
tool_code = fields.Char('功能刀具编码')
hilt_name = fields.Char('刀柄名称')
hilt_code = fields.Char('刀柄编码')
life_value_max = fields.Char('最大寿命值')
alarm_value = fields.Char('报警值')
used_value = fields.Char('已使用值')
code = fields.Char('机床刀位号')
name = fields.Char('', compute='_compute_name')
code = fields.Char('机床刀位号')
name = fields.Char('刀位号', compute='_compute_name')
@api.depends('code')
def _compute_name(self):

View File

@@ -398,6 +398,21 @@
</xpath>
<xpath expr="//page[1]" position="before">
<field name="results" invisible="1"/>
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<group>
<field name="test_results" widget="selection" attrs='{"invisible":[("results","!=",False)]}'/>
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
</group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认"
attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>
</div>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<field name="cnc_ids" widget="one2many" string="工作程序">
@@ -423,20 +438,6 @@
</group>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<field name="results" invisible="1"/>
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
<group>
<field name="test_results" widget="selection" attrs='{"invisible":[("results","!=",False)]}'/>
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
</group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认"
attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>
</div>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
<!-- <field name="tray_id" readonly="1"/>-->

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- 设备增加刀具库位table-->
设备增加刀具库位table
<record id="sf_manufacturing_hr_equipment_view_form" model="ir.ui.view">
<field name="name">sf_manufacturing_equipment.form</field>
<field name="model">maintenance.equipment</field>
@@ -13,17 +13,6 @@
<field name = 'product_template_ids' >
<tree editable='bottom'>
<field name="code"/>
<field name="product_template_id"/>
<field name="image_1920" widget="image"/>
<field name="categ_type"/>
<field name="diameter"/>
<field name="precision"/>
<field name="tool_code"/>
<field name="hilt_name"/>
<field name="hilt_code"/>
<field name="life_value_max"/>
<field name="alarm_value"/>
<field name="used_value"/>
</tree>
</field>
</page>