Compare commits
62 Commits
release/re
...
release_1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
609e65e36f | ||
|
|
fdfd01605d | ||
|
|
49d55822cc | ||
|
|
2db81ac2cc | ||
|
|
a673630fd3 | ||
|
|
6c5b888bba | ||
|
|
aa6b476e35 | ||
|
|
263253e79e | ||
|
|
edda681940 | ||
|
|
7043d2b8b7 | ||
|
|
6d66872dee | ||
|
|
3ab378f3bd | ||
|
|
26c979ef1d | ||
|
|
9aa4858774 | ||
|
|
d883a7ff22 | ||
|
|
17678c53c9 | ||
|
|
fb3cc095b2 | ||
|
|
c437c185a4 | ||
|
|
b3eb3ee8fa | ||
|
|
b9ec821293 | ||
|
|
f8a9fcc0ce | ||
|
|
d12714dd65 | ||
|
|
a1bea537bb | ||
|
|
5350675355 | ||
|
|
65d2593db9 | ||
|
|
a529c5513e | ||
|
|
f5f881f256 | ||
|
|
d2babec1aa | ||
|
|
f7723f1b9c | ||
|
|
ef80848e9b | ||
|
|
138dd40a9e | ||
|
|
dc210f7263 | ||
|
|
9055e7ed8b | ||
|
|
6890ddf615 | ||
|
|
c7df18ace6 | ||
|
|
053eba5887 | ||
|
|
e935b2fa11 | ||
|
|
d5bc610214 | ||
|
|
2ca67eb8ad | ||
|
|
b6a69debd8 | ||
|
|
147ac35239 | ||
|
|
3c3f375120 | ||
|
|
c87f310bb3 | ||
|
|
f53eecbb57 | ||
|
|
1743fa45b5 | ||
|
|
75f30922e6 | ||
|
|
3a0db05c33 | ||
|
|
5f42b5d056 | ||
|
|
c698b50853 | ||
|
|
251786f6be | ||
|
|
66b4df5193 | ||
|
|
57b264b84d | ||
|
|
ff12a86406 | ||
|
|
b0b3ce7d99 | ||
|
|
8d02a94f78 | ||
|
|
4f6e4a8ed3 | ||
|
|
b524e385a1 | ||
|
|
d22f08d187 | ||
|
|
2ba53bbb02 | ||
|
|
38e0a62130 | ||
|
|
bf1b14290e | ||
|
|
1b6ca90bd4 |
@@ -503,4 +503,22 @@ div:has(.o_required_modifier) > label::before {
|
||||
color: #fff;
|
||||
background-color: #4A4F59;
|
||||
border-color: #4A4F59;
|
||||
}
|
||||
|
||||
// 功能刀具组装单 弹窗样式
|
||||
.o_horizontal_separator.mt-4.mb-3.text-uppercase.fw-bolder.small ~ div.col-lg-6 .o_inner_group.col-lg-6 {
|
||||
width: 100%;
|
||||
}
|
||||
.o_horizontal_separator.mt-4.mb-3.text-uppercase.fw-bolder.small ~ div .o_inner_group .o_wrap_field.d-flex.d-sm-contents.flex-column{
|
||||
display: flex!important;
|
||||
flex-direction: row!important;
|
||||
input {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置表格横向滚动
|
||||
.o_list_renderer.o_renderer {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
.o_data_row .w-100 {
|
||||
width: 40px !important;
|
||||
height: 40px !important;
|
||||
display: block !important;
|
||||
//display: block !important;
|
||||
}
|
||||
|
||||
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import re
|
||||
import requests
|
||||
from itertools import groupby
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError,ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
|
||||
|
||||
@@ -315,7 +315,7 @@ class MrpProduction(models.Model):
|
||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
||||
else:
|
||||
production.write({'programming_no': production_programming.programming_no,
|
||||
'programming_state': '编程中'})
|
||||
'programming_state': '已编程' if production_programming.programming_state == '已编程' else '编程中'})
|
||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
@@ -379,6 +379,12 @@ class MrpProduction(models.Model):
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||
production.workorder_ids = workorders_values
|
||||
if production_programming.programming_state == '已编程':
|
||||
logging.info("production_programming: %s" % production_programming.name)
|
||||
production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({
|
||||
'cnc_ids': production_programming.workorder_ids.filtered(
|
||||
lambda
|
||||
t1: t1.routing_type == 'CNC加工').cnc_ids})
|
||||
for workorder in production.workorder_ids:
|
||||
workorder.duration_expected = workorder._get_duration_expected()
|
||||
|
||||
@@ -406,20 +412,15 @@ class MrpProduction(models.Model):
|
||||
|
||||
# 工单排序
|
||||
def _reset_work_order_sequence1(self, k):
|
||||
sequen = 0
|
||||
for rec in self:
|
||||
current_sequence = 10
|
||||
cnc_workorder = rec.workorder_ids.filtered(lambda wo: wo.name == "CNC加工")
|
||||
cnc_back_workorder = rec.workorder_ids.filtered(lambda wo: wo.name == "CNC加工(返工)")
|
||||
for work in rec.workorder_ids:
|
||||
work.sequence = current_sequence
|
||||
current_sequence += 10
|
||||
if work.name == '后置三元质量检测' and work.processing_panel == k:
|
||||
sequen = work.sequence
|
||||
|
||||
for work in rec.workorder_ids:
|
||||
if work.name == '后置三元质量检测(返工)' and work.processing_panel == k:
|
||||
work.sequence = sequen + 2
|
||||
if work.name == 'CNC加工(返工)' and work.processing_panel == k:
|
||||
work.sequence = sequen + 1
|
||||
if work.name == cnc_workorder.name and work.processing_panel == k:
|
||||
cnc_back_workorder.write({'sequence': work.sequence + 1})
|
||||
print(cnc_back_workorder.sequence)
|
||||
elif work.routing_type not in ['装夹预调'] and work != cnc_back_workorder:
|
||||
work.sequence += 1
|
||||
|
||||
# 在制造订单上新增工单
|
||||
def _create_workorder1(self, k):
|
||||
@@ -459,13 +460,7 @@ class MrpProduction(models.Model):
|
||||
order='sequence asc'
|
||||
)
|
||||
i += 1
|
||||
|
||||
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 == 'CNC加工':
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
|
||||
|
||||
@@ -677,13 +677,59 @@ class ResMrpWorkOrder(models.Model):
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||
self.production_id.company_id).create(
|
||||
values)
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
productions._create_workorder()
|
||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||
(
|
||||
p.move_dest_ids.procure_method != 'make_to_order' and
|
||||
not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||
for production_item in productions:
|
||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
|
||||
('is_subcontract', '=', True)])
|
||||
if process_parameter_workorder:
|
||||
is_pick = False
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
||||
for i in range(len(sorted_workorders) - 1):
|
||||
if m == 0:
|
||||
is_pick = False
|
||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
||||
if sorted_workorders[i] not in consecutive_workorders:
|
||||
consecutive_workorders.append(sorted_workorders[i])
|
||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
||||
m += 1
|
||||
continue
|
||||
else:
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||
production_item)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
||||
if is_pick is False:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||
production_item)
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||
production_item)
|
||||
if sorted_workorders[i] in consecutive_workorders:
|
||||
is_pick = True
|
||||
consecutive_workorders = []
|
||||
m = 0
|
||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
|
||||
if is_pick is False and m == 0:
|
||||
if len(sorted_workorders) == 1:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
|
||||
else:
|
||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
|
||||
|
||||
for production in productions:
|
||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||
@@ -704,6 +750,28 @@ class ResMrpWorkOrder(models.Model):
|
||||
'mail.message_origin_link',
|
||||
values={'self': production, 'origin': origin_production},
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
|
||||
'''
|
||||
创建生产计划
|
||||
'''
|
||||
# 工单耗时
|
||||
workorder_duration = 0
|
||||
for workorder in productions.workorder_ids:
|
||||
workorder_duration += workorder.duration_expected
|
||||
|
||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', productions.origin)])
|
||||
if sale_order:
|
||||
# sale_order.write({'schedule_status': 'to schedule'})
|
||||
self.env['sf.production.plan'].sudo().with_company(self.production_id.company_id).create({
|
||||
'name': productions.name,
|
||||
'order_deadline': sale_order.deadline_of_delivery,
|
||||
'production_id': productions.id,
|
||||
'date_planned_start': productions.date_planned_start,
|
||||
'origin': productions.origin,
|
||||
'product_qty': productions.product_qty,
|
||||
'product_id': productions.product_id.id,
|
||||
'state': 'draft',
|
||||
})
|
||||
if self.test_results == '返工':
|
||||
productions = self.production_id
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
@@ -720,7 +788,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
'name': '%s(返工)' % route.route_workcenter_id.name,
|
||||
'processing_panel': k,
|
||||
'routing_type': route.routing_type,
|
||||
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
|
||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
||||
route.routing_type,
|
||||
production.product_id),
|
||||
@@ -728,10 +795,38 @@ class ResMrpWorkOrder(models.Model):
|
||||
'date_planned_finished': datetime.now() + timedelta(days=1),
|
||||
'duration_expected': 60,
|
||||
'duration': 0,
|
||||
|
||||
'manual_quotation': production.workorder_ids.filtered(
|
||||
lambda t: t.routing_type == 'CNC加工').manual_quotation,
|
||||
'rfid_code': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').rfid_code,
|
||||
'cnc_ids': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').cnc_ids,
|
||||
'cmm_ids': production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').cmm_ids,
|
||||
}]
|
||||
return workorders_values_str
|
||||
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
|
||||
def _compute_state(self):
|
||||
super(ResMrpWorkOrder, self)._compute_state()
|
||||
for item in self:
|
||||
scrap_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
|
||||
('state', '=', 'done'), ('is_remanufacture', '=', True)])
|
||||
print(item.name)
|
||||
print(item.state)
|
||||
if item.name == 'CNC加工(返工)' and item.state not in ['ready', 'progress', 'done']:
|
||||
item.state = 'ready'
|
||||
if item.routing_type == '解除装夹':
|
||||
last_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', item.production_id.id), ('name', '=', 'CNC加工(返工)'),
|
||||
('state', '!=', 'done')])
|
||||
if item.state != 'pending':
|
||||
if last_workorder:
|
||||
item.state = 'pending'
|
||||
if scrap_workorder:
|
||||
item.state = 'cancel'
|
||||
elif item.routing_type == '表面工艺':
|
||||
if scrap_workorder:
|
||||
item.state = 'cancel'
|
||||
|
||||
# 重写工单开始按钮方法
|
||||
def button_start(self):
|
||||
if self.routing_type == '装夹预调':
|
||||
@@ -895,6 +990,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
record.write({
|
||||
'date_planned_finished': tem_date_planned_finished # 保持原值
|
||||
})
|
||||
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
|
||||
record.recreateManufacturingOrWorkerOrder()
|
||||
is_production_id = True
|
||||
for workorder in record.production_id.workorder_ids:
|
||||
if workorder.state != 'done':
|
||||
@@ -1039,8 +1136,10 @@ class CNCprocessing(models.Model):
|
||||
for f in files:
|
||||
if os.path.splitext(f)[1] == ".pdf":
|
||||
full_path = os.path.join(serverdir, root, f)
|
||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||
open(full_path, 'rb').read())
|
||||
if full_path is not False:
|
||||
if not cnc_processing.workorder_id.cnc_worksheet:
|
||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||
open(full_path, 'rb').read())
|
||||
else:
|
||||
if f in program_path:
|
||||
# if cnc_processing.program_name == f.split('.')[0]:
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<tree editable="bottom">
|
||||
<field name="name" required="1"/>
|
||||
<field name="type" readonly="1" string="任务类型"/>
|
||||
<field name="route_type" string="类型"/>
|
||||
<field name="route_type" string="类型" required="1"/>
|
||||
<field name="start_site_id" required="1" options="{'no_create': True}" string="起点接驳站"/>
|
||||
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
|
||||
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}) ]"/>
|
||||
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||
<!-- <field name="target">fullscreen</field>-->
|
||||
<field name="target">current</field>
|
||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||
@@ -477,7 +477,7 @@
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group>
|
||||
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
|
||||
<field name="is_remanufacture" attrs='{"invisible":[("test_results","=","合格")]}'/>
|
||||
<field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>
|
||||
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
|
||||
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
||||
widget="pdf_viewer"/>
|
||||
@@ -618,7 +618,6 @@
|
||||
<field name="route_id" options="{'no_create': True}"
|
||||
domain="[('route_type','in',['上产线','下产线'])]"/>
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||
<field name="is_cnc_program_down" readonly="1"/>
|
||||
<!-- <field name="rfid_code"/>-->
|
||||
|
||||
@@ -24,22 +24,12 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
ret = json.loads(datas)
|
||||
ret = json.loads(ret['result'])
|
||||
logging.info('下发编程单:%s' % ret)
|
||||
is_delete_file = False
|
||||
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
||||
cnc_production = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
||||
cnc_program = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search(
|
||||
[('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
|
||||
if cnc_production.workorder_ids.filtered(lambda a: a.routing_type == 'CNC加工').cnc_ids:
|
||||
is_delete_file = True
|
||||
cnc_production.workorder_ids.filtered(
|
||||
lambda a1: a1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_production)
|
||||
if cnc_program.workorder_ids.filtered(lambda c: c.routing_type == 'CNC加工').cnc_ids:
|
||||
cnc_program.workorder_ids.filtered(
|
||||
lambda c1: c1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_program)
|
||||
# cnc_program = request.env['mrp.production'].with_user(
|
||||
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
||||
logging.info('制造订单号:%s' % cnc_production.name)
|
||||
@@ -47,13 +37,6 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
# if ret['glb_file']:
|
||||
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||
# 拉取所有加工面的程序文件
|
||||
if is_delete_file is True:
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', 'R')
|
||||
files_r = os.listdir(program_path_tmp_r)
|
||||
if files_r:
|
||||
for file_name in files_r:
|
||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
os.remove(file_path)
|
||||
for r in ret['processing_panel']:
|
||||
download_state = request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).download_file_tmp(
|
||||
@@ -81,17 +64,15 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
if cnc_processing:
|
||||
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
||||
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
||||
cnc_production.workorder_ids.filtered(lambda g: g.routing_type == '装夹预调').write(
|
||||
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
||||
lambda g1: g1.routing_type == 'CNC加工').cnc_worksheet})
|
||||
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
||||
if cnc_program and cnc_processing_arr:
|
||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
cnc_program.workorder_ids.filtered(lambda d: d.routing_type == '装夹预调').write(
|
||||
cnc_program.workorder_ids.filtered(lambda b1: b1.routing_type == '装夹预调').write(
|
||||
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
||||
lambda d1: d1.routing_type == 'CNC加工').cnc_worksheet})
|
||||
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
||||
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
||||
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
||||
cnc_program |= cnc_production
|
||||
if not cnc_program and cnc_processing_arr:
|
||||
cnc_program = cnc_production
|
||||
|
||||
@@ -32,6 +32,9 @@ class FtpController():
|
||||
logging.error(f"Error checking file: {e}")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
# # 检测字符串的编码
|
||||
# def detect_encoding(self, s):
|
||||
# result = chardet.detect(s)
|
||||
|
||||
@@ -8,35 +8,6 @@ from odoo.http import request
|
||||
|
||||
class Manufacturing_Connect(http.Controller):
|
||||
|
||||
@http.route('/AutoDeviceApi/ToolGroup', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_functional_tool_groups_Info(self, **kw):
|
||||
"""
|
||||
刀具组接口
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('get_functional_tool_groups_Info:%s' % kw)
|
||||
try:
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
# ret = json.loads(ret['result'])
|
||||
logging.info('DeviceId:%s' % ret)
|
||||
functional_tools = request.env['sf.tool.inventory'].sudo().search([])
|
||||
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
if functional_tools:
|
||||
for item in functional_tools:
|
||||
res['Datas'].append({
|
||||
'GroupName': item.tool_groups_id.name,
|
||||
'ToolId': item.functional_cutting_tool_model_id.name,
|
||||
'ToolName': item.name
|
||||
})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_functional_tool_groups_Info error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/ToolInventory', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_functional_tool_inventory_Info(self, **kw):
|
||||
@@ -126,4 +97,4 @@ class Manufacturing_Connect(http.Controller):
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('put_tool_preset_parameter_port error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<field name="model_id" ref="model_sf_tool_datasync"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._cron_tool_datasync_all()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="interval_number">12</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -311,53 +311,41 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
||||
'applicant': None,
|
||||
'sf_functional_tool_assembly_id': None})
|
||||
|
||||
def create_cam_work_plan(self, cnc_processing_ids):
|
||||
def create_cam_work_plan(self, cnc_processing):
|
||||
"""
|
||||
根据传入的工单信息,查询是否有需要的功能刀具,如果没有则生成CAM工单程序用刀计划
|
||||
"""
|
||||
for cnc_processing in cnc_processing_ids:
|
||||
status = False
|
||||
if cnc_processing.cutting_tool_name:
|
||||
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
||||
[('name', '=', cnc_processing.cutting_tool_name)])
|
||||
if functional_tools:
|
||||
for functional_tool in functional_tools:
|
||||
if functional_tool.on_tool_stock_num == 0:
|
||||
if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
|
||||
status = True
|
||||
else:
|
||||
status = True
|
||||
if status:
|
||||
knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
|
||||
'name': cnc_processing.workorder_id.production_id.name,
|
||||
'cam_procedure_code': cnc_processing.program_name,
|
||||
'filename': cnc_processing.cnc_id.name,
|
||||
'functional_tool_name': cnc_processing.cutting_tool_name,
|
||||
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
|
||||
'process_type': cnc_processing.processing_type,
|
||||
'margin_x_y': float(cnc_processing.margin_x_y),
|
||||
'margin_z': float(cnc_processing.margin_z),
|
||||
'finish_depth': float(cnc_processing.depth_of_processing_z),
|
||||
'extension_length': float(cnc_processing.cutting_tool_extension_length),
|
||||
'shank_model': cnc_processing.cutting_tool_handle_type,
|
||||
'estimated_processing_time': cnc_processing.estimated_processing_time,
|
||||
})
|
||||
logging.info('CAM工单程序用刀计划创建成功!!!')
|
||||
# 创建装刀请求
|
||||
knife_plan.apply_for_tooling()
|
||||
else:
|
||||
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
||||
|
||||
def unlink_cam_plan(self, production):
|
||||
for item in production:
|
||||
cam_plan_ids = self.env['sf.cam.work.order.program.knife.plan'].search([('name', '=', item.name)])
|
||||
for cam_plan_id in cam_plan_ids:
|
||||
assembly_id = cam_plan_id.sf_functional_tool_assembly_id
|
||||
if assembly_id.assemble_status in ('0', '待组装') and not assembly_id.start_preset_bool:
|
||||
logging.info('%s删除成功!!!' % assembly_id)
|
||||
assembly_id.sudo().unlink()
|
||||
logging.info('unlink_cam_plan成功!!!')
|
||||
cam_plan_ids.sudo().unlink()
|
||||
status = False
|
||||
if cnc_processing.cutting_tool_name:
|
||||
functional_tools = self.env['sf.real.time.distribution.of.functional.tools'].sudo().search(
|
||||
[('name', '=', cnc_processing.cutting_tool_name)])
|
||||
if functional_tools:
|
||||
for functional_tool in functional_tools:
|
||||
if functional_tool.on_tool_stock_num == 0:
|
||||
if functional_tool.tool_stock_num == 0 and functional_tool.side_shelf_num == 0:
|
||||
status = True
|
||||
else:
|
||||
status = True
|
||||
if status:
|
||||
knife_plan = self.env['sf.cam.work.order.program.knife.plan'].sudo().create({
|
||||
'name': cnc_processing.workorder_id.production_id.name,
|
||||
'cam_procedure_code': cnc_processing.program_name,
|
||||
'filename': cnc_processing.cnc_id.name,
|
||||
'functional_tool_name': cnc_processing.cutting_tool_name,
|
||||
'cam_cutter_spacing_code': cnc_processing.cutting_tool_no,
|
||||
'process_type': cnc_processing.processing_type,
|
||||
'margin_x_y': float(cnc_processing.margin_x_y),
|
||||
'margin_z': float(cnc_processing.margin_z),
|
||||
'finish_depth': float(cnc_processing.depth_of_processing_z),
|
||||
'extension_length': float(cnc_processing.cutting_tool_extension_length),
|
||||
'shank_model': cnc_processing.cutting_tool_handle_type,
|
||||
'estimated_processing_time': cnc_processing.estimated_processing_time,
|
||||
})
|
||||
logging.info('CAM工单程序用刀计划创建成功!!!')
|
||||
# 创建装刀请求
|
||||
knife_plan.apply_for_tooling()
|
||||
else:
|
||||
logging.info('功能刀具【%s】满足CNC用刀需求!!!' % cnc_processing.cutting_tool_name)
|
||||
|
||||
|
||||
class FunctionalToolAssembly(models.Model):
|
||||
@@ -555,8 +543,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True)
|
||||
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
||||
string='组装后功能刀具类型', readonly=True)
|
||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True,
|
||||
digits=(10, 3))
|
||||
after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True, digits=(10, 3))
|
||||
after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True, digits=(10, 3))
|
||||
after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True)
|
||||
cut_time = fields.Integer(string='已切削时间(min)', readonly=True)
|
||||
@@ -570,7 +557,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)', readonly=True)
|
||||
after_assembly_used_value = fields.Integer(string='组装后已使用值(min)', readonly=True)
|
||||
after_assembly_tool_loading_length = fields.Float(string='组装后总长度(mm)', readonly=True, digits=(10, 3))
|
||||
after_assembly_handle_length = fields.Float(string='组装后刀柄长度(mm)', readonly=True, digits=(10, 3))
|
||||
after_assembly_handle_length = fields.Float(string='组装后刀柄长度(mm)',readonly=True, digits=(10, 3))
|
||||
after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)', readonly=True, digits=(10, 3))
|
||||
after_assembly_effective_length = fields.Float(string='组装后有效长(mm)', readonly=True)
|
||||
L_D_number = fields.Float(string='L/D值(mm)', readonly=True)
|
||||
@@ -864,10 +851,6 @@ class FunctionalToolDismantle(models.Model):
|
||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||
# 对拆解的功能刀具进行校验,只有在刀具房的功能刀具才能拆解
|
||||
if self.functional_tool_id.tool_room_num == 0:
|
||||
raise ValidationError('Rfid为【%s】的功能刀具当前位置为【%s】,不能进行拆解!' % (
|
||||
self.rfid, self.functional_tool_id.current_location))
|
||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
location_dest = self.env['stock.location'].search([('name', '=', '刀具房')])
|
||||
# =================刀柄是否[报废]拆解=======
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import base64
|
||||
import requests
|
||||
import logging
|
||||
from odoo import models, api
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import UserError
|
||||
@@ -10,30 +11,36 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = '夹具物料序列号注册'
|
||||
|
||||
def enroll_fixture_material_stock(self):
|
||||
def sync_enroll_fixture_material_stock_all(self):
|
||||
logging.info("调用 sync_enroll_fixture_material_stock_all 同步接口")
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
||||
product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '夹具')]).ids
|
||||
objs_all = self.env['stock.lot'].search([('rfid', '!=', False), ('product_id', 'in', product_ids)])
|
||||
fixture_material_stock_list = []
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'name': item.name,
|
||||
'tool_material_status': item.tool_material_status,
|
||||
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
|
||||
'fixture_material_search_id': item.fixture_material_search_id.id,
|
||||
}
|
||||
fixture_material_stock_list.append(val)
|
||||
kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '夹具物料序列号注册成功'
|
||||
else:
|
||||
raise UserError("没有注册夹具物料序列号信息")
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'name': item.name,
|
||||
'tool_material_status': item.tool_material_status,
|
||||
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
|
||||
'fixture_material_search_id': item.fixture_material_search_id.id,
|
||||
}
|
||||
fixture_material_stock_list.append(val)
|
||||
kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("夹具物料序列号每日同步成功")
|
||||
return '夹具物料序列号注册成功'
|
||||
else:
|
||||
logging.info("没有注册夹具物料序列号信息")
|
||||
except Exception as e:
|
||||
logging.info("夹具物料序列号同步失败:%s" % e)
|
||||
|
||||
|
||||
class FixtureMaterialSearch(models.Model):
|
||||
@@ -42,41 +49,46 @@ class FixtureMaterialSearch(models.Model):
|
||||
|
||||
crea_url = "/api/fixture_material/create"
|
||||
|
||||
def enroll_fixture_material(self):
|
||||
def sync_enroll_fixture_material_all(self):
|
||||
logging.info("调用 sync_enroll_fixture_material_all 同步接口")
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.search([('id', '=', self.id)])
|
||||
objs_all = self.search([])
|
||||
fixture_material_list = []
|
||||
if objs_all:
|
||||
for obj in objs_all:
|
||||
val = {
|
||||
'name': obj.name,
|
||||
'id': obj.id,
|
||||
'fixture_material_code': obj.fixture_material_id.code,
|
||||
'fixture_model_code': obj.fixture_model_id.code,
|
||||
'specification_name': obj.specification_fixture_id.name,
|
||||
'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
|
||||
'number': obj.number,
|
||||
'usable_num': obj.usable_num,
|
||||
'have_been_used_num': obj.have_been_used_num,
|
||||
'scrap_num': obj.scrap_num
|
||||
}
|
||||
fixture_material_list.append(val)
|
||||
kw = json.dumps(fixture_material_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '夹具物料注册成功'
|
||||
else:
|
||||
raise UserError("没有注册夹具物料信息")
|
||||
try:
|
||||
if objs_all:
|
||||
for obj in objs_all:
|
||||
val = {
|
||||
'name': obj.name,
|
||||
'id': obj.id,
|
||||
'fixture_material_code': obj.fixture_material_id.code,
|
||||
'fixture_model_code': obj.fixture_model_id.code,
|
||||
'specification_name': obj.specification_fixture_id.name,
|
||||
'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
|
||||
'number': obj.number,
|
||||
'usable_num': obj.usable_num,
|
||||
'have_been_used_num': obj.have_been_used_num,
|
||||
'scrap_num': obj.scrap_num
|
||||
}
|
||||
fixture_material_list.append(val)
|
||||
kw = json.dumps(fixture_material_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("夹具物料每日同步成功")
|
||||
return '夹具物料注册成功'
|
||||
else:
|
||||
logging.info("没有注册夹具物料信息")
|
||||
except Exception as e:
|
||||
logging.info("夹具物料同步失败:%s" % e)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||
for record in records:
|
||||
if record:
|
||||
record.enroll_fixture_material()
|
||||
return records
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record:
|
||||
# record.enroll_fixture_material()
|
||||
# return records
|
||||
|
||||
@@ -33,23 +33,26 @@ def get_suitable_coolant_names(item):
|
||||
|
||||
class ToolDatasync(models.Model):
|
||||
_name = 'sf.tool.datasync'
|
||||
_description = '定时同步所有刀具'
|
||||
_description = '定时同步所有刀具、夹具'
|
||||
|
||||
def _cron_tool_datasync_all(self):
|
||||
try:
|
||||
self.env['stock.lot'].sudo().sync_enroll_tool_material_stock_all()
|
||||
logging.info("刀具物料序列号每日同步成功")
|
||||
|
||||
self.env['stock.lot'].sudo().sync_enroll_fixture_material_stock_all()
|
||||
|
||||
self.env['sf.tool.material.search'].sudo().sync_enroll_tool_material_all()
|
||||
logging.info("刀具物料每日同步成功")
|
||||
|
||||
self.env['sf.fixture.material.search'].sudo().sync_enroll_fixture_material_all()
|
||||
|
||||
self.env['sf.functional.cutting.tool.entity'].sudo().esync_enroll_functional_tool_entity_all()
|
||||
logging.info("功能刀具列表每日同步成功")
|
||||
self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
|
||||
logging.info("功能刀具预警每日同步成功")
|
||||
self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
|
||||
logging.info("功能刀具出入库记录每日同步成功")
|
||||
self.env[
|
||||
'sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
|
||||
logging.info("功能刀具安全库存每日同步成功")
|
||||
logging.info("已全部同步完成!!!")
|
||||
# self.env['sf.functional.tool.warning'].sudo().sync_enroll_functional_tool_warning_all()
|
||||
# logging.info("功能刀具预警每日同步成功")
|
||||
# self.env['stock.move.line'].sudo().sync_enroll_functional_tool_move_all()
|
||||
# logging.info("功能刀具出入库记录每日同步成功")
|
||||
# self.env['sf.real.time.distribution.of.functional.tools'].sudo().sync_enroll_functional_tool_real_time_distribution_all()
|
||||
# logging.info("功能刀具安全库存每日同步成功")
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||
@@ -59,24 +62,25 @@ class StockLot(models.Model):
|
||||
_inherit = 'stock.lot'
|
||||
_description = '刀具物料序列号注册'
|
||||
|
||||
def enroll_tool_material_stock(self):
|
||||
logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
|
||||
self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||
# def enroll_tool_material_stock(self):
|
||||
# logging.info('调用刀具物料序列号注册接口: enroll_tool_material_stock()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
# objs_all = self.env['stock.lot'].search([('id', '=', self.id), ('active', 'in', [True, False])])
|
||||
# self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_tool_material_stock_all(self):
|
||||
logging.info('调用刀具物料序列号注册接口: sync_enroll_tool_material_stock_all()')
|
||||
logging.info('调用 sync_enroll_tool_material_stock_all 同步接口')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||
objs_all = self.env['stock.lot'].search([('rfid', '!=', False)])
|
||||
product_ids = self.env['product.product'].sudo().search([('categ_type', '=', '刀具')]).ids
|
||||
objs_all = self.env['stock.lot'].search([('rfid', '!=', False), ('product_id', 'in', product_ids)])
|
||||
self._get_sync_stock_lot(objs_all, str_url, token, headers)
|
||||
|
||||
def _get_sync_stock_lot(self, objs_all, str_url, token, headers):
|
||||
@@ -95,11 +99,12 @@ class StockLot(models.Model):
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return '刀具物料序列号注册成功'
|
||||
logging.info("刀具物料序列号每日同步成功")
|
||||
return '刀具(夹具)物料序列号注册成功'
|
||||
else:
|
||||
logging.info("没有注册刀具物料序列号信息")
|
||||
logging.info("没有刀具物料序列号信息")
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
logging.info("刀具物料序列号同步失败:%s" % e)
|
||||
|
||||
|
||||
class ToolMaterial(models.Model):
|
||||
@@ -108,18 +113,18 @@ class ToolMaterial(models.Model):
|
||||
|
||||
crea_url = '/api/tool_material/create'
|
||||
|
||||
def enroll_tool_material(self):
|
||||
logging.info('调用刀具物料注册接口: enroll_tool_material()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.search([('id', '=', self.id)])
|
||||
self._get_sync_tool_material_search(objs_all, str_url, token, headers)
|
||||
# def enroll_tool_material(self):
|
||||
# logging.info('调用刀具物料注册接口: enroll_tool_material()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.search([('id', '=', self.id)])
|
||||
# self._get_sync_tool_material_search(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_tool_material_all(self):
|
||||
logging.info('调用刀具物料注册接口: sync_enroll_tool_material_all()')
|
||||
logging.info('调用 sync_enroll_tool_material_all 同步接口')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
@@ -150,11 +155,20 @@ class ToolMaterial(models.Model):
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("刀具物料每日同步成功")
|
||||
return '刀具物料注册成功'
|
||||
else:
|
||||
logging.info('没有注册刀具物料信息')
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
logging.info("刀具物料同步失败:%s" % e)
|
||||
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(ToolMaterial, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record:
|
||||
# record.enroll_tool_material()
|
||||
# return records
|
||||
|
||||
|
||||
class FunctionalCuttingToolEntity(models.Model):
|
||||
@@ -164,18 +178,18 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
crea_url = "/api/functional_tool_entity/create"
|
||||
|
||||
# 注册同步功能刀具列表
|
||||
def enroll_functional_tool_entity(self):
|
||||
logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
|
||||
self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
|
||||
# def enroll_functional_tool_entity(self):
|
||||
# logging.info('调用功能刀具列表注册接口: enroll_functional_tool_entity()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['sf.functional.cutting.tool.entity'].search([('id', '=', self.id)])
|
||||
# self._get_sync_functional_cutting_tool_entity(objs_all, str_url, token, headers)
|
||||
|
||||
def esync_enroll_functional_tool_entity_all(self):
|
||||
logging.info('调用功能刀具列表注册接口: esync_enroll_functional_tool_entity_all()')
|
||||
logging.info('调用 esync_enroll_functional_tool_entity_all 同步接口')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
@@ -202,6 +216,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
'coarse_middle_thin': item.coarse_middle_thin,
|
||||
'new_former': item.new_former,
|
||||
'tool_loading_length': item.tool_loading_length,
|
||||
'handle_length': item.handle_length,
|
||||
'functional_tool_length': item.functional_tool_length,
|
||||
'effective_length': item.effective_length,
|
||||
'max_lifetime_value': item.max_lifetime_value,
|
||||
@@ -234,212 +249,257 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
logging.info("功能刀具列表每日同步成功")
|
||||
return "功能刀具注册成功"
|
||||
else:
|
||||
logging.info('没有注册功能刀具信息')
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
logging.info("功能刀具同步失败:%s" % e)
|
||||
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(FunctionalCuttingToolEntity, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record:
|
||||
# record.enroll_functional_tool_entity()
|
||||
# return records
|
||||
|
||||
class FunctionalToolWarning(models.Model):
|
||||
_inherit = 'sf.functional.tool.warning'
|
||||
_description = '功能刀具预警注册'
|
||||
# def write(self, vals):
|
||||
# res = super().write(vals)
|
||||
# if vals.get('current_location'):
|
||||
# self.enroll_functional_tool_entity()
|
||||
# return res
|
||||
|
||||
crea_url = "/api/functional_tool_warning/create"
|
||||
|
||||
# 注册同步功能刀具预警
|
||||
def enroll_functional_tool_warning(self):
|
||||
logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
|
||||
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_functional_tool_warning_all(self):
|
||||
logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_all()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['sf.functional.tool.warning'].search([])
|
||||
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
|
||||
def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
||||
tool_warning_list = []
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'id': item.id,
|
||||
'name': item.name,
|
||||
'code': item.code,
|
||||
'rfid': item.rfid,
|
||||
'tool_groups_name': item.tool_groups_id.name,
|
||||
'production_line': item.production_line_id.name,
|
||||
'machine_tool_id': item.maintenance_equipment_id.code,
|
||||
'machine_tool_code': item.machine_tool_code,
|
||||
'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
||||
'functional_tool_name': item.name,
|
||||
'barcode': item.barcode_id.name,
|
||||
'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
||||
'diameter': item.diameter,
|
||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'max_lifetime_value': item.max_lifetime_value,
|
||||
'alarm_value': item.alarm_value,
|
||||
'used_value': item.used_value,
|
||||
'functional_tool_status': item.functional_tool_status,
|
||||
'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'dispose_user': item.dispose_user,
|
||||
'dispose_time': item.dispose_time,
|
||||
'dispose_func': item.dispose_func,
|
||||
}
|
||||
tool_warning_list.append(val)
|
||||
kw = json.dumps(tool_warning_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return "功能刀具预警注册成功"
|
||||
else:
|
||||
logging.info('没有注册功能刀具预警信息')
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
_inherit = 'stock.move.line'
|
||||
_description = '功能刀具出入库记录注册'
|
||||
|
||||
crea_url = "/api/functional_tool_move/create"
|
||||
|
||||
# 注册同步功能刀具出入库记录
|
||||
def enroll_functional_tool_move(self):
|
||||
logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
||||
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_functional_tool_move_all(self):
|
||||
logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_all()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
||||
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
|
||||
def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
||||
tool_stock_list = []
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
val = {
|
||||
'id': item.id,
|
||||
'name': item.functional_tool_name,
|
||||
'code': item.code,
|
||||
'rfid': item.rfid,
|
||||
'tool_groups_name': item.tool_groups_id.name,
|
||||
'reference': item.reference,
|
||||
'barcode': item.lot_id.name,
|
||||
'functional_tool_type_code': item.functional_tool_type_id.code,
|
||||
'diameter': item.diameter,
|
||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'location_id': item.location_id.name,
|
||||
'location_dest_name': item.location_dest_id.name,
|
||||
'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'qty_done': item.qty_done,
|
||||
}
|
||||
tool_stock_list.append(val)
|
||||
kw = json.dumps(tool_stock_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return "功能刀具出入库记录注册成功"
|
||||
else:
|
||||
logging.info('没有注册功能刀具出入库记录信息')
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
|
||||
|
||||
class RealTimeDistributionFunctionalTools(models.Model):
|
||||
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
||||
_description = '功能刀具安全库存注册'
|
||||
|
||||
crea_url = "/api/functional_tool_distribution/create"
|
||||
|
||||
# 注册同步功能刀具预警
|
||||
def enroll_functional_tool_real_time_distribution(self):
|
||||
logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
||||
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
|
||||
def sync_enroll_functional_tool_real_time_distribution_all(self):
|
||||
logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_all()')
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([])
|
||||
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
|
||||
def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
||||
tool_distribution_list = []
|
||||
try:
|
||||
if objs_all:
|
||||
for item in objs_all:
|
||||
functional_tool_codes = []
|
||||
for obj in item.sf_functional_tool_entity_ids:
|
||||
functional_tool_codes.append(obj.code)
|
||||
val = {
|
||||
'id': item.id,
|
||||
'name': item.name,
|
||||
'tool_groups_name': item.tool_groups_id.name,
|
||||
'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
||||
'diameter': item.diameter,
|
||||
'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
'tool_stock_num': item.tool_stock_num,
|
||||
'side_shelf_num': item.side_shelf_num,
|
||||
'on_tool_stock_num': item.on_tool_stock_num,
|
||||
'tool_stock_total': item.tool_stock_total,
|
||||
'min_stock_num': item.min_stock_num,
|
||||
'max_stock_num': item.max_stock_num,
|
||||
'batch_replenishment_num': item.batch_replenishment_num,
|
||||
'unit': item.unit,
|
||||
'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
|
||||
'functional_tool_codes': str(functional_tool_codes),
|
||||
'coarse_middle_thin': item.coarse_middle_thin,
|
||||
'whether_standard_knife': item.whether_standard_knife,
|
||||
'suitable_machining_method_names': get_suitable_machining_method_names(item),
|
||||
'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
|
||||
'handle_type_name': item.handle_type_id.name,
|
||||
'cutting_direction_names': get_cutting_direction_names(item),
|
||||
'suitable_coolant_names': get_suitable_coolant_names(item),
|
||||
'active': item.active
|
||||
}
|
||||
tool_distribution_list.append(val)
|
||||
kw = json.dumps(tool_distribution_list, ensure_ascii=False)
|
||||
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if ret.get('code') == 200:
|
||||
return "功能刀具出入库记录注册成功"
|
||||
else:
|
||||
logging.info('没有注册功能刀具出入库记录信息')
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
#
|
||||
# class FunctionalToolWarning(models.Model):
|
||||
# _inherit = 'sf.functional.tool.warning'
|
||||
# _description = '功能刀具预警注册'
|
||||
#
|
||||
# crea_url = "/api/functional_tool_warning/create"
|
||||
#
|
||||
# # 注册同步功能刀具预警
|
||||
# def enroll_functional_tool_warning(self):
|
||||
# logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
|
||||
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def sync_enroll_functional_tool_warning_all(self):
|
||||
# logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_all()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['sf.functional.tool.warning'].search([])
|
||||
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
||||
# tool_warning_list = []
|
||||
# try:
|
||||
# if objs_all:
|
||||
# for item in objs_all:
|
||||
# val = {
|
||||
# 'id': item.id,
|
||||
# 'name': item.name,
|
||||
# 'code': item.code,
|
||||
# 'rfid': item.rfid,
|
||||
# 'tool_groups_name': item.tool_groups_id.name,
|
||||
# 'production_line': item.production_line_id.name,
|
||||
# 'machine_tool_id': item.maintenance_equipment_id.code,
|
||||
# 'machine_tool_code': item.machine_tool_code,
|
||||
# 'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
||||
# 'functional_tool_name': item.name,
|
||||
# 'barcode': item.barcode_id.name,
|
||||
# 'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
||||
# 'diameter': item.diameter,
|
||||
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'max_lifetime_value': item.max_lifetime_value,
|
||||
# 'alarm_value': item.alarm_value,
|
||||
# 'used_value': item.used_value,
|
||||
# 'functional_tool_status': item.functional_tool_status,
|
||||
# 'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'dispose_user': item.dispose_user,
|
||||
# 'dispose_time': item.dispose_time,
|
||||
# 'dispose_func': item.dispose_func,
|
||||
# }
|
||||
# tool_warning_list.append(val)
|
||||
# kw = json.dumps(tool_warning_list, ensure_ascii=False)
|
||||
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
# ret = r.json()
|
||||
# if ret.get('code') == 200:
|
||||
# return "功能刀具预警注册成功"
|
||||
# else:
|
||||
# logging.info('没有注册功能刀具预警信息')
|
||||
# except Exception as e:
|
||||
# logging.info("捕获错误信息:%s" % e)
|
||||
#
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(FunctionalToolWarning, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record:
|
||||
# record.enroll_functional_tool_warning()
|
||||
# return records
|
||||
#
|
||||
#
|
||||
# class StockMoveLine(models.Model):
|
||||
# _inherit = 'stock.move.line'
|
||||
# _description = '功能刀具出入库记录注册'
|
||||
#
|
||||
# crea_url = "/api/functional_tool_move/create"
|
||||
#
|
||||
# # 注册同步功能刀具出入库记录
|
||||
# def enroll_functional_tool_move(self):
|
||||
# logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
||||
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def sync_enroll_functional_tool_move_all(self):
|
||||
# logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_all()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
||||
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
||||
# tool_stock_list = []
|
||||
# try:
|
||||
# if objs_all:
|
||||
# for item in objs_all:
|
||||
# val = {
|
||||
# 'id': item.id,
|
||||
# 'name': item.functional_tool_name,
|
||||
# 'code': item.code,
|
||||
# 'rfid': item.rfid,
|
||||
# 'tool_groups_name': item.tool_groups_id.name,
|
||||
# 'reference': item.reference,
|
||||
# 'barcode': item.lot_id.name,
|
||||
# 'functional_tool_type_code': item.functional_tool_type_id.code,
|
||||
# 'diameter': item.diameter,
|
||||
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'location_id': item.location_id.name,
|
||||
# 'location_dest_name': item.location_dest_id.name,
|
||||
# 'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
# 'qty_done': item.qty_done,
|
||||
# }
|
||||
# tool_stock_list.append(val)
|
||||
# kw = json.dumps(tool_stock_list, ensure_ascii=False)
|
||||
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
# ret = r.json()
|
||||
# if ret.get('code') == 200:
|
||||
# return "功能刀具出入库记录注册成功"
|
||||
# else:
|
||||
# logging.info('没有注册功能刀具出入库记录信息')
|
||||
# except Exception as e:
|
||||
# logging.info("捕获错误信息:%s" % e)
|
||||
#
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(StockMoveLine, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record.functional_tool_name_id:
|
||||
# record.enroll_functional_tool_move()
|
||||
# return records
|
||||
#
|
||||
#
|
||||
# class RealTimeDistributionFunctionalTools(models.Model):
|
||||
# _inherit = 'sf.real.time.distribution.of.functional.tools'
|
||||
# _description = '功能刀具安全库存注册'
|
||||
#
|
||||
# crea_url = "/api/functional_tool_distribution/create"
|
||||
#
|
||||
# # 注册同步功能刀具预警
|
||||
# def enroll_functional_tool_real_time_distribution(self):
|
||||
# logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
||||
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def sync_enroll_functional_tool_real_time_distribution_all(self):
|
||||
# logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_all()')
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||
# objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([])
|
||||
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
||||
#
|
||||
# def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
||||
# tool_distribution_list = []
|
||||
# try:
|
||||
# if objs_all:
|
||||
# for item in objs_all:
|
||||
# functional_tool_codes = []
|
||||
# for obj in item.sf_functional_tool_entity_ids:
|
||||
# functional_tool_codes.append(obj.code)
|
||||
# val = {
|
||||
# 'id': item.id,
|
||||
# 'name': item.name,
|
||||
# 'tool_groups_name': item.tool_groups_id.name,
|
||||
# 'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
||||
# 'diameter': item.diameter,
|
||||
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
||||
# 'tool_stock_num': item.tool_stock_num,
|
||||
# 'side_shelf_num': item.side_shelf_num,
|
||||
# 'on_tool_stock_num': item.on_tool_stock_num,
|
||||
# 'tool_stock_total': item.tool_stock_total,
|
||||
# 'min_stock_num': item.min_stock_num,
|
||||
# 'max_stock_num': item.max_stock_num,
|
||||
# 'batch_replenishment_num': item.batch_replenishment_num,
|
||||
# 'unit': item.unit,
|
||||
# 'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
|
||||
# 'functional_tool_codes': str(functional_tool_codes),
|
||||
# 'coarse_middle_thin': item.coarse_middle_thin,
|
||||
# 'whether_standard_knife': item.whether_standard_knife,
|
||||
# 'suitable_machining_method_names': get_suitable_machining_method_names(item),
|
||||
# 'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
|
||||
# 'handle_type_name': item.handle_type_id.name,
|
||||
# 'cutting_direction_names': get_cutting_direction_names(item),
|
||||
# 'suitable_coolant_names': get_suitable_coolant_names(item),
|
||||
# 'active': item.active
|
||||
# }
|
||||
# tool_distribution_list.append(val)
|
||||
# kw = json.dumps(tool_distribution_list, ensure_ascii=False)
|
||||
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
# ret = r.json()
|
||||
# if ret.get('code') == 200:
|
||||
# return "功能刀具出入库记录注册成功"
|
||||
# else:
|
||||
# logging.info('没有注册功能刀具出入库记录信息')
|
||||
# except Exception as e:
|
||||
# logging.info("捕获错误信息:%s" % e)
|
||||
#
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# records = super(RealTimeDistributionFunctionalTools, self).create(vals_list)
|
||||
# for record in records:
|
||||
# if record:
|
||||
# record.enroll_functional_tool_real_time_distribution()
|
||||
# return records
|
||||
#
|
||||
# def write(self, vals):
|
||||
# res = super().write(vals)
|
||||
# if vals.get('sf_functional_tool_entity_ids') or vals.get('min_stock_num') or vals.get('max_stock_num'):
|
||||
# self.enroll_functional_tool_real_time_distribution()
|
||||
# return res
|
||||
|
||||
@@ -61,12 +61,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
|
||||
def write_maintenance_equipment_tool(self, datas):
|
||||
if datas:
|
||||
# 清除设备机床刀位的刀具信息
|
||||
for obj in self.product_template_ids:
|
||||
obj.write({
|
||||
'functional_tool_name_id': False,
|
||||
'tool_install_time': None
|
||||
})
|
||||
for data in datas:
|
||||
maintenance_equipment_id = self.search([('name', '=', data['DeviceId'])])
|
||||
if maintenance_equipment_id:
|
||||
@@ -134,9 +128,12 @@ class StockLot(models.Model):
|
||||
record.tool_material_status = '报废'
|
||||
else:
|
||||
record.tool_material_status = '未入库'
|
||||
if record.fixture_material_search_id:
|
||||
# 注册夹具物料状态到cloud平台
|
||||
record.enroll_fixture_material_stock()
|
||||
# if record.tool_material_search_id:
|
||||
# # 注册刀具物料状态到cloud平台
|
||||
# record.enroll_tool_material_stock()
|
||||
# elif record.fixture_material_search_id:
|
||||
# # 注册夹具物料状态到cloud平台
|
||||
# record.enroll_fixture_material_stock()
|
||||
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
|
||||
@@ -45,6 +45,8 @@ class ToolMaterial(models.Model):
|
||||
record.have_been_used_num = have_been_used_num
|
||||
record.scrap_num = scrap_num
|
||||
record.number = usable_num + have_been_used_num + scrap_num
|
||||
# 更新数据到cloud的动态数据
|
||||
# record.enroll_tool_material()
|
||||
|
||||
@api.model
|
||||
def _read_group_cutting_tool_material_id(self, categories, domain, order):
|
||||
|
||||
Reference in New Issue
Block a user