1.新增机台日计划接口
2.新工件预调(前置三元检测)接口 3.,新NC程序下载接口接口
This commit is contained in:
@@ -19,3 +19,13 @@ class Common(models.Model):
|
|||||||
'TIMESTAMP': str(timestamp),
|
'TIMESTAMP': str(timestamp),
|
||||||
'checkstr': check_sf_str}
|
'checkstr': check_sf_str}
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
|
def get_add_time(self, parse_time):
|
||||||
|
"""
|
||||||
|
把时间增加8小时
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
dt = datetime.datetime.strptime(parse_time, "%Y-%m-%d %H:%M:%S")
|
||||||
|
d = dt + datetime.timedelta(hours=8)
|
||||||
|
nTime = d.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
return nTime
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import base64
|
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
|
|
||||||
@@ -40,3 +39,109 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('get_Work_Info error:%s' % e)
|
logging.info('get_Work_Info error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
@http.route('/AutoDeviceApi/GetShiftPlan', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_ShiftPlan(self, **kw):
|
||||||
|
"""
|
||||||
|
自动化每天获取机台日计划
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('get_ShiftPlan:%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([('name', '=', ret['ProductionLine'])])
|
||||||
|
if workorder:
|
||||||
|
for item in workorder:
|
||||||
|
date_planned_start = ''
|
||||||
|
date_planned_finished = ''
|
||||||
|
if item.date_planned_start is not False:
|
||||||
|
planned_start = item.date_planned_start.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
date_planned_start = request.env['sf.sync.common'].sudo().get_add_time(planned_start)
|
||||||
|
if item.date_planned_finished is not False:
|
||||||
|
planned_finished = item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
date_planned_finished = request.env['sf.sync.common'].sudo().get_add_time(planned_finished)
|
||||||
|
res['Datas'].append({
|
||||||
|
'BillId': item.production_id.name,
|
||||||
|
'RfidCode': item.RfidCode,
|
||||||
|
'CraftName': item.name,
|
||||||
|
'Quantity': 1,
|
||||||
|
'WortkStart': date_planned_start,
|
||||||
|
'WorkEnd': date_planned_finished,
|
||||||
|
'MaterialId': item.product_id.default_code,
|
||||||
|
'MaterialName': item.product_id.name,
|
||||||
|
# 'Spec':item.mat,
|
||||||
|
'Material': item.materials_type_id.name
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
logging.info('get_ShiftPlan error:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_qcCheck(self, **kw):
|
||||||
|
"""
|
||||||
|
工件预调(前置三元检测)
|
||||||
|
1、前置三元检测在产线外:三元检测设备把测量信息上传给MES,
|
||||||
|
MES生成检测定位数据。中控系统传递RFID编号给MES获取测量偏置结果。(来源为三元检测工单上的字段)
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('get_qcCheck:%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
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
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,
|
||||||
|
cors="*")
|
||||||
|
def get_qcCheck(self, **kw):
|
||||||
|
"""
|
||||||
|
工件预调(前置三元检测)
|
||||||
|
1、前置三元检测在产线外:三元检测设备把测量信息上传给MES,
|
||||||
|
MES生成检测定位数据。中控系统传递RFID编号给MES获取测量偏置结果。(来源为三元检测工单上的字段)
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
logging.info('get_qcCheck:%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
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
|
logging.info('get_qcCheck error:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user