Accept Merge Request #1188: (feature/优化制造功能 -> develop)
Merge Request: 设备oee界面优化;增加由dashboard调用的接口 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1188?initial=true
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
from . import models
|
from . import models
|
||||||
from . import wizard
|
from . import wizard
|
||||||
|
from . import controllers
|
||||||
|
|||||||
1
sf_machine_connect/controllers/__init__.py
Normal file
1
sf_machine_connect/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import controllers
|
||||||
98
sf_machine_connect/controllers/controllers.py
Normal file
98
sf_machine_connect/controllers/controllers.py
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import ast
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
|
||||||
|
|
||||||
|
class Sf_Dashboard_Connect(http.Controller):
|
||||||
|
|
||||||
|
@http.route('/api/get_machine_datas/list', type='http', auth='public', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_machine_datas_list(self, **kw):
|
||||||
|
"""
|
||||||
|
拿到机床数据返回给大屏展示
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
res = {'status': 1, 'message': '成功', 'data': []}
|
||||||
|
logging.info('前端请求机床数据的参数为:%s' % kw)
|
||||||
|
# tem_list = [
|
||||||
|
# "XT-GNJC-WZZX-X800-Y550-Z550-T24-A5-1", "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-3",
|
||||||
|
# "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-4", "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-5",
|
||||||
|
# "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-6", "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-7",
|
||||||
|
# "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-8", "XT-GNJC-WZZX-X800-Y550-Z550-T24-A5-2",
|
||||||
|
# "XT-GNJC-GSZG-X600-Y400-Z350-T21-A3-9", "XT-GNJC-GSZG-X600-Y400-Z350-T21-A3-10",
|
||||||
|
# "XT-GNJC-GSZG-X600-Y400-Z350-T21-A3-11", "XT-GNJC-GSZG-X600-Y400-Z350-T21-A3-12",
|
||||||
|
# "XT-GNJC-GSZG-X600-Y400-Z350-T21-A3-13", "XT-GNJC-GSZG-X600-Y400-Z350-T21-A3-14"
|
||||||
|
# ]
|
||||||
|
try:
|
||||||
|
equipment_obj = request.env['maintenance.equipment'].sudo()
|
||||||
|
# 获取请求的机床数据
|
||||||
|
machine_list = ast.literal_eval(kw['machine_list'])
|
||||||
|
for item in machine_list:
|
||||||
|
machine_data = equipment_obj.search([('code', '=', item)])
|
||||||
|
if machine_data:
|
||||||
|
res['data'].append({
|
||||||
|
'id': machine_data.id,
|
||||||
|
'name': machine_data.name,
|
||||||
|
'code': machine_data.code,
|
||||||
|
'status': machine_data.status,
|
||||||
|
'run_status': machine_data.run_status,
|
||||||
|
'run_time': machine_data.run_time,
|
||||||
|
'system_date': machine_data.system_date,
|
||||||
|
'system_time': machine_data.system_time,
|
||||||
|
'cut_time': machine_data.cut_time,
|
||||||
|
'cut_status': machine_data.cut_status,
|
||||||
|
'program': machine_data.program,
|
||||||
|
'program_name': machine_data.program_name,
|
||||||
|
'program_status': machine_data.program_status,
|
||||||
|
'tool_num': machine_data.tool_num,
|
||||||
|
'machine_power_on_time': machine_data.machine_power_on_time,
|
||||||
|
'product_counts': machine_data.product_counts,
|
||||||
|
'mode': machine_data.mode,
|
||||||
|
'start_time': machine_data.start_time,
|
||||||
|
'end_time': machine_data.end_time,
|
||||||
|
'program_start_time': machine_data.program_start_time,
|
||||||
|
'program_end_time': machine_data.program_end_time,
|
||||||
|
'standby_start_time': machine_data.standby_start_time,
|
||||||
|
'standby_end_time': machine_data.standby_end_time,
|
||||||
|
'offline_start_time': machine_data.offline_start_time,
|
||||||
|
'offline_end_time': machine_data.offline_end_time,
|
||||||
|
'emg_status': machine_data.emg_status,
|
||||||
|
'current_program': machine_data.current_program,
|
||||||
|
'current_program_seq': machine_data.current_program_seq,
|
||||||
|
'x_abs_pos': machine_data.x_abs_pos,
|
||||||
|
'y_abs_pos': machine_data.y_abs_pos,
|
||||||
|
'z_abs_pos': machine_data.z_abs_pos,
|
||||||
|
'feed_speed_set': machine_data.feed_speed_set,
|
||||||
|
'act_feed_speed': machine_data.act_feed_speed,
|
||||||
|
'spindle_speed_set': machine_data.spindle_speed_set,
|
||||||
|
'act_spindle_speed': machine_data.act_spindle_speed,
|
||||||
|
'spindle_load': machine_data.spindle_load,
|
||||||
|
'x_axis_load': machine_data.x_axis_load,
|
||||||
|
'y_axis_load': machine_data.y_axis_load,
|
||||||
|
'z_axis_load': machine_data.z_axis_load,
|
||||||
|
'rapid_feed': machine_data.rapid_feed,
|
||||||
|
'feed_rate': machine_data.feed_rate,
|
||||||
|
'x_mach_coord': machine_data.x_mach_coord,
|
||||||
|
'y_mach_coord': machine_data.y_mach_coord,
|
||||||
|
'z_mach_coord': machine_data.z_mach_coord,
|
||||||
|
'x_rel_coord': machine_data.x_rel_coord,
|
||||||
|
'y_rel_coord': machine_data.y_rel_coord,
|
||||||
|
'z_rel_coord': machine_data.z_rel_coord,
|
||||||
|
'x_dis_coord': machine_data.x_dis_coord,
|
||||||
|
'y_dis_coord': machine_data.y_dis_coord,
|
||||||
|
'z_dis_coord': machine_data.z_dis_coord,
|
||||||
|
'alarm_time': machine_data.alarm_time,
|
||||||
|
'alarm_msg': machine_data.alarm_msg,
|
||||||
|
'clear_time': machine_data.clear_time,
|
||||||
|
})
|
||||||
|
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('前端请求机床数据失败,原因:%s' % e)
|
||||||
|
res['status'] = -1
|
||||||
|
res['message'] = '前端请求机床数据失败,原因:%s' % e
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
@@ -208,24 +208,22 @@ class Machine_ftp(models.Model):
|
|||||||
# 机床采集项目
|
# 机床采集项目
|
||||||
timestamp = fields.Datetime('时间戳', readonly=True)
|
timestamp = fields.Datetime('时间戳', readonly=True)
|
||||||
status = fields.Boolean('机床在线状态', readonly=True)
|
status = fields.Boolean('机床在线状态', readonly=True)
|
||||||
run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '加工中')], string='机床运行状态',
|
# run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '加工中')], string='机床运行状态',
|
||||||
readonly=True, default='0')
|
# readonly=True, default='0')
|
||||||
|
run_status = fields.Char('机床运行状态', readonly=True)
|
||||||
run_time = fields.Char('机床累计运行时长', readonly=True)
|
run_time = fields.Char('机床累计运行时长', readonly=True)
|
||||||
# 机床系统日期
|
# 机床系统日期
|
||||||
system_date = fields.Char('机床系统日期', readonly=True)
|
system_date = fields.Char('机床系统日期', readonly=True)
|
||||||
# 机床系统时间
|
# 机床系统时间
|
||||||
system_time = fields.Char('机床系统时间', readonly=True)
|
system_time = fields.Char('机床系统时间', readonly=True)
|
||||||
|
|
||||||
cut_time = fields.Char('机床累计切削时间', readonly=True)
|
cut_time = fields.Char('机床累计切削时间', readonly=True)
|
||||||
cut_status = fields.Selection([('0', '未切削'), ('1', '切削中'), ('2', '切削中'), ('3', '切削中')], string='机床当前切削状态',
|
# cut_status = fields.Selection([('0', '未切削'), ('1', '切削中'), ('2', '切削中'), ('3', '切削中')], string='机床当前切削状态',
|
||||||
readonly=True, default='0')
|
# readonly=True, default='0')
|
||||||
|
cut_status = fields.Char('机床当前切削状态', readonly=True)
|
||||||
# 当前程序名
|
# 当前程序名
|
||||||
|
|
||||||
program = fields.Char('机床当前程序', readonly=True)
|
program = fields.Char('机床当前程序', readonly=True)
|
||||||
|
|
||||||
# 当前刀具号
|
# 当前刀具号
|
||||||
tool_num = fields.Integer('机床当前刀具号', readonly=True)
|
tool_num = fields.Integer('机床当前刀具号', readonly=True)
|
||||||
|
|
||||||
# 机床通电开机时间, 机床加工件数, 机床当前操作模式, 开始加工时间, 结束加工时间, 加工程序开始时间, 加工程序结束时间, 待机开始时间,
|
# 机床通电开机时间, 机床加工件数, 机床当前操作模式, 开始加工时间, 结束加工时间, 加工程序开始时间, 加工程序结束时间, 待机开始时间,
|
||||||
# 待机结束时间, 机床离线开始时间, 机床离线结束时间, 机床急停状态, 机床主程序名称, 程序运行的状态, 机床当前执行指令, 机床当前执行语句号
|
# 待机结束时间, 机床离线开始时间, 机床离线结束时间, 机床急停状态, 机床主程序名称, 程序运行的状态, 机床当前执行指令, 机床当前执行语句号
|
||||||
# 机床X轴当前位置, 机床Y轴当前位置, 机床Z轴当前位置
|
# 机床X轴当前位置, 机床Y轴当前位置, 机床Z轴当前位置
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class SfMaintenanceEquipmentOEELog(models.Model):
|
|||||||
_description = '设备运行日志'
|
_description = '设备运行日志'
|
||||||
|
|
||||||
equipment_id = fields.Many2one('maintenance.equipment', '机台号')
|
equipment_id = fields.Many2one('maintenance.equipment', '机台号')
|
||||||
name = fields.Char('设备名称')
|
equipment_code = fields.Char('设备编码')
|
||||||
|
name = fields.Char('设备名称', readonly='True')
|
||||||
machine_tool_picture = fields.Binary('设备图片')
|
machine_tool_picture = fields.Binary('设备图片')
|
||||||
type_id = fields.Many2one('sf.machine_tool.type', '品牌型号')
|
type_id = fields.Many2one('sf.machine_tool.type', '品牌型号')
|
||||||
state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"),
|
state = fields.Selection([("加工", "加工"), ("关机", "关机"), ("待机", "待机"), ("故障", "故障"),
|
||||||
@@ -70,6 +71,11 @@ class SfMaintenanceEquipmentOEELog(models.Model):
|
|||||||
# work_nums = fields.Integer('加工件数')
|
# work_nums = fields.Integer('加工件数')
|
||||||
equipment_oee_id = fields.Many2one('maintenance.equipment.oee', '设备OEE')
|
equipment_oee_id = fields.Many2one('maintenance.equipment.oee', '设备OEE')
|
||||||
|
|
||||||
|
@api.onchange('equipment_id')
|
||||||
|
def get_name(self):
|
||||||
|
self.name = self.equipment_id.name
|
||||||
|
self.equipment_code = self.equipment_id.code
|
||||||
|
|
||||||
|
|
||||||
# 设备运行日志详情
|
# 设备运行日志详情
|
||||||
class SfMaintenanceEquipmentOEELogDetail(models.Model):
|
class SfMaintenanceEquipmentOEELogDetail(models.Model):
|
||||||
|
|||||||
@@ -68,5 +68,5 @@ access_sf_cutting_tool_type_group_purchase_director_sf_group_equipment_user,sf_c
|
|||||||
access_sf_cutting_tool_type_group_sale_director_sf_group_equipment_user,sf_cutting_tool_type_group_sale_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0
|
access_sf_cutting_tool_type_group_sale_director_sf_group_equipment_user,sf_cutting_tool_type_group_sale_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0
|
||||||
access_sf_cutting_tool_type_group_plan_director_sf_group_equipment_user,sf_cutting_tool_type_group_plan_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0
|
access_sf_cutting_tool_type_group_plan_director_sf_group_equipment_user,sf_cutting_tool_type_group_plan_director,sf_base.model_sf_cutting_tool_type,sf_maintenance.sf_group_equipment_user,1,0,0,0
|
||||||
|
|
||||||
access_maintenance_equipment_oee_logs,maintenance_equipment_oee_logs,model_maintenance_equipment_oee_logs,sf_maintenance.sf_group_equipment_manager,1,1,1,0
|
access_maintenance_equipment_oee_logs,maintenance_equipment_oee_logs,model_maintenance_equipment_oee_logs,sf_maintenance.sf_group_equipment_manager,1,1,1,1
|
||||||
access_maintenance_equipment_oee_log_detail,maintenance_equipment_oee_log_detail,model_maintenance_equipment_oee_log_detail,sf_maintenance.sf_group_equipment_manager,1,1,1,0
|
access_maintenance_equipment_oee_log_detail,maintenance_equipment_oee_log_detail,model_maintenance_equipment_oee_log_detail,sf_maintenance.sf_group_equipment_manager,1,1,1,1
|
||||||
|
@@ -156,6 +156,7 @@
|
|||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="equipment_id" domain="[('name','ilike','加工中心')]"/>
|
||||||
<field name="type_id"/>
|
<field name="type_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</group>
|
</group>
|
||||||
@@ -195,8 +196,27 @@
|
|||||||
</group>
|
</group>
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="日志详情">
|
<page string="24H日志详情">
|
||||||
|
<!-- 筛选出24小时内的日志 -->
|
||||||
|
<!-- <field name="detail_ids" domain="[('time','<',(datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S'))]"> -->
|
||||||
|
<field name="detail_ids" domain="[('state','ilike','加工')]">
|
||||||
|
<tree>
|
||||||
|
<field name="sequence"/>
|
||||||
|
<field name="time"/>
|
||||||
|
<field name="state"/>
|
||||||
|
<field name="production_id"/>
|
||||||
|
</tree>
|
||||||
|
<!-- <form> -->
|
||||||
|
<!-- <field name="sequence"/> -->
|
||||||
|
<!-- <field name="time"/> -->
|
||||||
|
<!-- <field name="state"/> -->
|
||||||
|
<!-- <field name="production_id"/> -->
|
||||||
|
<!-- </form> -->
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
<page string="历史日志详情">
|
||||||
<field name="detail_ids">
|
<field name="detail_ids">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
@@ -256,22 +276,15 @@
|
|||||||
<field name="model">maintenance.equipment.oee.log.detail</field>
|
<field name="model">maintenance.equipment.oee.log.detail</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="设备运行日志详情">
|
<form string="设备运行日志详情">
|
||||||
<header>
|
|
||||||
<field name="sequence" readonly="1"/>
|
|
||||||
</header>
|
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_title">
|
|
||||||
<h1>
|
|
||||||
<field name="time" readonly="1"/>
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="state" readonly="1"/>
|
<field name="state"/>
|
||||||
<field name="production_id" readonly="1"/>
|
<field name="production_id"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="log_id"/>
|
<field name="sequence"/>
|
||||||
|
<field name="time"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
|||||||
Reference in New Issue
Block a user