Accept Merge Request #685: (feature/制造代码优化 -> develop)

Merge Request: 修改机床链接模块,优化规范代码

Created By: @马广威
Accepted By: @马广威
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/685?initial=true
This commit is contained in:
马广威
2023-11-22 14:24:35 +08:00
committed by Coding
9 changed files with 87 additions and 85 deletions

View File

@@ -1,8 +1,8 @@
import cpca
import base64
import logging
from datetime import datetime
import requests
import cpca
from odoo.exceptions import UserError
from odoo.exceptions import ValidationError
from odoo import api, fields, models, SUPERUSER_ID, _

View File

@@ -22,20 +22,21 @@
'views/ftp_button.xml',
'views/compensation.xml',
# 只有它被屏蔽了
# 'views/SfWorkOrderBarcodes.xml',
'views/WorkCenterBarcodes.xml',
'views/Stock_picking_Barcodes.xml',
# 'views/machine_monitor.xml',
'views/machine_monitor.xml',
'views/machine_info_present.xml',
'views/delivery_record.xml',
'views/res_config_settings_views.xml',
],
'assets': {
'web.assets_backend': [
# 'sf_machine_connect/static/src/xml/barcode_button.xml',
# 'sf_machine_connect/static/src/js/barcode_button.js',
# 'sf_machine_connect/static/src/css/barcode_button.css',
'web.assets_backend': [
# 'sf_machine_connect/static/src/xml/barcode_button.xml',
# 'sf_machine_connect/static/src/js/barcode_button.js',
# 'sf_machine_connect/static/src/css/barcode_button.css',
],
},

View File

@@ -60,11 +60,11 @@ class FtpButton(models.Model):
raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host
port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd
remote_path = self.workorder_id.workcenter_id.machine_tool_id.ftp_remote_path
host = self.workorder_id.equipment_id.ftp_host
port = self.workorder_id.equipment_id.ftp_port
username = self.workorder_id.equipment_id.ftp_num
pwd = self.workorder_id.equipment_id.ftp_pwd
remote_path = self.workorder_id.equipment_id.ftp_remote_path
print(host, port, username, pwd, remote_path)
ftp = ftp_operate.FtpController(host, port, username, pwd)
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
@@ -107,8 +107,8 @@ class FtpButton(models.Model):
下发NC代码前自动补偿三元检测偏差值
:return:
"""
hongbianliang550 = self.workorder_id.workcenter_id.machine_tool_id.x_compensation_node
hongbianliang551 = self.workorder_id.workcenter_id.machine_tool_id.y_compensation_node
hongbianliang550 = self.workorder_id.equipment_id.x_compensation_node
hongbianliang551 = self.workorder_id.equipment_id.y_compensation_node
try:
temp_dict = {}
temp_dict[hongbianliang550] = self.workorder_id.compensation_value_x
@@ -124,9 +124,9 @@ class Machine_ftp(models.Model):
"""
数据采集类
"""
_inherit = 'sf.machine_tool'
_inherit = 'maintenance.equipment'
workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单')
# workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单')
# 机床配置项目
# ftp相关
@@ -263,7 +263,7 @@ class WorkCenterBarcode(models.Model):
compensation_value_y = fields.Float(string='Y轴补偿值')
button_compensation_state = fields.Boolean(string='是否已经补偿', readonly=True)
button_up_all_state = fields.Boolean(string='是否已经全部下发', readonly=True)
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
machine_tool_id = fields.Many2one('sf.machine_tool.type', string='机床')
machine_tool_name = fields.Char(string='机床名称', default='未知机床', compute='_run_info', readonly=True)
machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_run_info', readonly=True)
machine_tool_status = fields.Boolean(string='在线状态', compute='_run_info', readonly=True)
@@ -281,27 +281,27 @@ class WorkCenterBarcode(models.Model):
machine_tool_compensation_value_y = fields.Char('y补偿值', compute='_run_info', readonly=True)
delivery_records = fields.One2many('delivery.record', 'workorder_id', string="下发记录")
@api.depends('workcenter_id.machine_tool_id.timestamp')
@api.depends('equipment_id.timestamp')
def _run_info(self):
# self.machine_tool_name = '1号机床'
self.machine_tool_name = self.workcenter_id.machine_tool_id.name
self.machine_tool_type_id = self.workcenter_id.machine_tool_id.type_id.name
self.machine_tool_status = self.workcenter_id.machine_tool_id.status
self.machine_tool_run_status = self.workcenter_id.machine_tool_id.run_status
self.machine_tool_timestamp = self.workcenter_id.machine_tool_id.timestamp
self.machine_tool_time_on = self.workcenter_id.machine_tool_id.time_on
self.machine_tool_time_on_now = self.workcenter_id.machine_tool_id.time_on_now
self.machine_tool_tool_num = self.workcenter_id.machine_tool_id.tool_num
self.machine_tool_program = self.workcenter_id.machine_tool_id.program
self.machine_tool_machine_ip = self.workcenter_id.machine_tool_id.machine_ip
self.machine_tool_cut_status = self.workcenter_id.machine_tool_id.cut_status
self.machine_tool_name = self.equipment_id.name
self.machine_tool_type_id = self.equipment_id.type_id.name
self.machine_tool_status = self.equipment_id.status
self.machine_tool_run_status = self.equipment_id.run_status
self.machine_tool_timestamp = self.equipment_id.timestamp
self.machine_tool_time_on = self.equipment_id.time_on
self.machine_tool_time_on_now = self.equipment_id.time_on_now
self.machine_tool_tool_num = self.equipment_id.tool_num
self.machine_tool_program = self.equipment_id.program
self.machine_tool_machine_ip = self.equipment_id.machine_ip
self.machine_tool_cut_status = self.equipment_id.cut_status
self.machine_tool_compensation_value_x = self.compensation_value_x
self.machine_tool_compensation_value_y = self.compensation_value_y
def compensation(self):
hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node
hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node
hongbianliang550 = self.equipment_id.x_compensation_node
hongbianliang551 = self.equipment_id.y_compensation_node
try:
temp_dict = {}
temp_dict[hongbianliang550] = self.compensation_value_x
@@ -339,11 +339,11 @@ class WorkCenterBarcode(models.Model):
except Exception:
raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
sequence_collect = []
host = self.workcenter_id.machine_tool_id.ftp_host
port = self.workcenter_id.machine_tool_id.ftp_port
username = self.workcenter_id.machine_tool_id.ftp_num
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
host = self.equipment_id.ftp_host
port = self.equipment_id.ftp_port
username = self.equipment_id.ftp_num
pwd = self.equipment_id.ftp_pwd
remote_path = self.equipment_id.ftp_remote_path
_logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd))
ftp = ftp_operate.FtpController(host, port, username, pwd)
_logger.info("=====================1777777777111================")
@@ -403,11 +403,11 @@ class WorkCenterBarcode(models.Model):
except Exception:
raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
sequence_collect = []
host = self.workcenter_id.machine_tool_id.ftp_host
port = self.workcenter_id.machine_tool_id.ftp_port
username = self.workcenter_id.machine_tool_id.ftp_num
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
host = self.equipment_id.ftp_host
port = self.equipment_id.ftp_port
username = self.equipment_id.ftp_num
pwd = self.equipment_id.ftp_pwd
remote_path = self.equipment_id.ftp_remote_path
_logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd))
ftp = ftp_operate.FtpController(host, port, username, pwd)
_logger.info("=====================1777777777111================")

View File

@@ -91,7 +91,6 @@ class FtpController:
"""
self.ftp.close()
def delAllfile(self, ftppath):
"""
删除ftp服务器端全部文件

View File

@@ -26,11 +26,11 @@ class Py2opcua:
"""
# try:
self.client.connect()
# print("opcua服务器连接成功可以写入")
# return self.client
# print("opcua服务器连接成功可以写入")
# return self.client
# except Exception as e:
# print("opcua服务器连接失败请检查" + str(e))
# temp_dict = temp_dict
# temp_dict = temp_dict
temp_list = list(temp_dict.items())
for i in range(len(temp_list)):
# 寻找节点上的变量

View File

@@ -10,7 +10,7 @@ class ResBFMConfigSettings(models.TransientModel):
bfm_url = fields.Selection(
[("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"),
("https://bfm.r.jikimo.com", "测试环境(https://bfm.r.jikimo.com)"),
("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"),
# ("正式环境", "https://bfm.jikimo.com")], string='bfm环境', store=True)
("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True)

View File

@@ -2,14 +2,14 @@
<odoo>
<record id="view_tree_mrs_machine_tool_inherited" model="ir.ui.view">
<field name="name">sf_base_extension</field>
<field name="model">sf.machine_tool</field>
<field name="inherit_id" ref="sf_base.sf_machine_tool_form"/>
<field name="model">maintenance.equipment</field>
<field name="inherit_id" ref="sf_maintenance.sf_hr_equipment_view_form"/>
<field eval="20" name="priority"/>
<field name="arch" type="xml">
<!-- <xpath expr="//field[@name='knife_type']" position="before">-->
<xpath expr="//form//notebook//page[1]" position="inside">
<xpath expr="//form//notebook//page[1]" position="after">
<!-- <xpath expr="//page[@name='other']" position="before">-->
<notebook>
<!-- <notebook> -->
<page string="机床监控">
<group string='状态监控'>
<group>
@@ -256,49 +256,51 @@
</group>
</group>
</page>
</notebook>
<!-- </notebook> -->
</xpath>
</field>
</record>
<record id="view_cutting_tool_inherited" model="ir.ui.view">
<field name="name">sf_cutting_tool_extension</field>
<field name="model">sf.cutting_tool.type</field>
<field name="inherit_id" ref="sf_base.form_sf_cutting_tool_type"/>
<field name="arch" type="xml">
<xpath expr="//form//group" position="after">
<group string='刀具寿命'>
<group>
<field name="total_cut_time"/>
<field name="tool_position"/>
</group>
<group>
<field name="predict_life_time"/>
<!-- 刀具寿命 -->
<!-- <record id="view_cutting_tool_inherited" model="ir.ui.view"> -->
<!-- <field name="name">sf_cutting_tool_extension</field> -->
<!-- <field name="model">sf.cutting_tool.type</field> -->
<!-- <field name="inherit_id" ref="sf_base.form_sf_machine_tool_type"/> -->
<!-- <field name="arch" type="xml"> -->
<!-- <xpath expr="//form//group" position="after"> -->
<!-- <group string='刀具寿命'> -->
<!-- <group> -->
<!-- <field name="total_cut_time"/> -->
<!-- <field name="tool_position"/> -->
</group>
<!-- </group> -->
<!-- <group> -->
<!-- <field name="predict_life_time"/> -->
<div>
<!-- </group> -->
<div>
<field name='is_connect_tool_position' invisible='1'/>
<button string="绑定刀位" name="tool_connect_machine" type="object" confirm="是否确认绑定此刀位"
class="btn-primary"/>
<!-- <div> -->
<!-- <div> -->
<!-- <field name='is_connect_tool_position' invisible='1'/> -->
<!-- <button string="绑定刀位" name="tool_connect_machine" type="object" confirm="是否确认绑定此刀位" -->
<!-- class="btn-primary"/> -->
<!-- attrs='{"invisible": [("is_connect_tool_position","!=", -->
<!-- "False")]}' -->
<span>&#32;</span>
<button string="解绑刀位" name="tool_unconnect_machine" type="object" confirm="是否解绑此刀位"
class="btn-primary"/>
<!-- <span>&#32;</span> -->
<!-- <button string="解绑刀位" name="tool_unconnect_machine" type="object" confirm="是否解绑此刀位" -->
<!-- class="btn-primary"/> -->
<!-- attrs='{"invisible": [("is_connect_tool_position","!=", -->
<!-- "False")]}' -->
</div>
<!-- </div> -->
</div>
</group>
</xpath>
</field>
</record>
<!-- </div> -->
<!-- </group> -->
<!-- </xpath> -->
<!-- </field> -->
<!-- </record> -->
</odoo>

View File

@@ -13,9 +13,9 @@ class CustomKanbanController extends KanbanController {
async setup() {
super.setup();
console.log('99999999111');
// console.log('99999999111');
this.workOrders = await this.getAllWorkOrders();
this.workOrdersNew = this.workOrders;
// this.workOrdersNew = this.workOrders;
// console.log('lines222222222', this.workOrders);
//
// console.log(typeof this.workOrders);
@@ -39,14 +39,14 @@ class CustomKanbanController extends KanbanController {
const id = button.getAttribute('data-id');
console.log('true_id', id);
const context = {production_line_show: 'shengchanxian1'}
// const context = {production_line_show: 'shengchanxian1'}
this.env.services.rpc('/web/dataset/call_kw', {
model: 'mrp.workcenter',
method: 'search_read',
args: [[], ['id']],
kwargs: {}
}).then((records) => {
console.log(records)
// console.log(records)
const ids = records.map(record => record.id);
const context = {production_line_show: id};
this.env.services.rpc('/web/dataset/call_kw', {
@@ -55,7 +55,7 @@ class CustomKanbanController extends KanbanController {
args: [ids, context],
kwargs: {}
}).then((response) => {
console.log('response', response);
// console.log('response', response);
location.reload();
window.onload = function () {
button.classList.add('choose')
@@ -77,7 +77,7 @@ class CustomKanbanController extends KanbanController {
// args: [],
// kwargs: {},
// });
console.log('response', response);
// console.log('response', response);
// console.log('response1', response1);
// 你可以在这里处理响应,例如将其存储在控制器的状态中
return response;

View File

@@ -42,7 +42,7 @@ export class StepViewer extends Component {
// url = "web_widget_model_viewer/static/src/images/not_model.png";
}
} else {
var oImg = document.getElementsByClassName('test')[0]
// var oImg = document.getElementsByClassName('test')[0]
// console.log(oImg)
}
}