Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug

This commit is contained in:
qihao.gong@jikimo.com
2024-02-23 09:56:16 +08:00
12 changed files with 171 additions and 74 deletions

View File

@@ -22,13 +22,13 @@ class Manufacturing_Connect(http.Controller):
ret = json.loads(datas)
logging.info('RfidCode:%s' % ret['RfidCode'])
if 'RfidCode' in ret:
workorder = request.env['mrp.workorder'].sudo().search(
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', '装夹预调')])
workorder = request.env['mrp.workorder'].sudo().search([('rfid_code', '=', ret['RfidCode'])])
if workorder:
for item in workorder:
res['Datas'].append({
'BillId': item.production_id.name,
'ProductionLine': item.production_id.production_line_id.id,
'SortId': item.sequence,
'CraftName': item.name,
'Quantity': 1,
'MaterialId': item.product_id.default_code,
@@ -60,11 +60,13 @@ class Manufacturing_Connect(http.Controller):
datas = request.httprequest.data
ret = json.loads(datas)
if 'ProductionLine' in ret:
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
else:
ProductionLine = False
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
logging.info('RfidCode:%s' % ret)
logging.info('workorder_ids:%s' % workorder_ids)
workorder = request.env['mrp.workorder'].sudo().search(workorder_ids)
if workorder:
for item in workorder:
date_planned_start = ''
@@ -119,7 +121,8 @@ class Manufacturing_Connect(http.Controller):
'XOffset': 0 if not item.material_center_point else offset[0],
'YOffset': 0 if not item.material_center_point else offset[1],
'ZOffet': 0 if not item.material_center_point else offset[2],
'COffset': 'G54' if not item.X_deviation_angle else item.X_deviation_angle
'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle,
'Coordinate': 'G54'
})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工件预调(前置三元检测)工单'}
@@ -293,17 +296,15 @@ class Manufacturing_Connect(http.Controller):
logging.info('NCProgDolod error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/LocationChange', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def NCProgDolod(self, **kw):
def LocationChange(self, **kw):
"""
库位变更
:param kw:
:return:
"""
logging.info('NCProgDolod:%s' % kw)
logging.info('LocationChange:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
@@ -315,6 +316,62 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('NCProgDolod error:%s' % e)
logging.info('LocationChange error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def AGVToProduct(self, **kw):
"""
AGV运送上产线完成
:param kw:
:return:
"""
logging.info('AGVToProduct:%s' % kw)
try:
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination', '=', ret['DeviceId'])])
if workpiece_delivery:
workpiece_delivery.production_id.write({'production_line_state': '已上产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVToProduct error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def AGVDownProduct(self, **kw):
"""
MES调度AGV搬运零件AGV托盘到产线接驳站。
生产线接受到零件AGV托盘到位信号后把生产合格或特采的零件机器人搬运零件到AGV接驳站中触发AGV运送下产线接口。
:param kw:
:return:
"""
logging.info('AGVDownProduct:%s' % kw)
try:
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination', '=', ret['DeviceId'])])
if workpiece_delivery:
workpiece_delivery.production_id.write({'production_line_state': '已下产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVDownProduct error:%s' % e)
return json.JSONEncoder().encode(res)

View File

@@ -52,6 +52,8 @@ 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='待上产线')
@api.depends(

View File

@@ -135,6 +135,17 @@ 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')
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',
string='上/下产线', store=True)
@api.onchange('rfid_code')
def compute_rfid(self):
workorder = self.env['mrp.workorder'].search([('production_id', '=', self.production_id)])
if workorder:
for item in workorder:
item.rfid_code = self.rfid_code
def get_plan_workorder(self, production_line):
tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d")
@@ -149,7 +160,7 @@ class ResMrpWorkOrder(models.Model):
params = [tomorrow, tomorrow, tomorrow, tomorrow]
if production_line:
sql += "AND production_line_id = %s"
params.append(production_line)
params.append(production_line)
self.env.cr.execute(sql, params)
ids = [t[0] for t in self.env.cr.fetchall()]
return [('id', 'in', ids)]
@@ -875,5 +886,3 @@ class CMMprogram(models.Model):
post_processing_name = fields.Char('后处理名称')
program_date = fields.Datetime('程序日期')
workorder_id = fields.Many2one('mrp.workorder', string="工单")

View File

@@ -69,8 +69,9 @@
<field name="programming_no" readonly="1"/>
<field name="work_state" invisible="1"/>
<field name="programming_state" readonly="1"/>
<field name="production_line_id" readonly="1"/>
<field name="production_line_id" readonly="1"/>
<field name="plan_start_processing_time" readonly="1"/>
<field name="production_line_state" readonly="1"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" data-hotkey="z"

View File

@@ -170,14 +170,15 @@
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="equipment_id"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="production_line_state"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="functional_fixture_id"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_code" force_save="1"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_type_id" force_save="1"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code" force_save="1"/>
</group>
<group attrs='{"invisible": [("routing_type","=","获取CNC加工程序")]}'>
<div>