cnc获取

This commit is contained in:
jinling.yang
2022-11-22 21:18:15 +08:00
parent cc739a218e
commit 11a360222e
5 changed files with 26 additions and 20 deletions

View File

@@ -33,7 +33,7 @@ class ResWorkcenter(models.Model):
AND equipment_id IS NOT NULL
AND maintenance_equipment.workcenter_id IS NOT NULL
AND maintenance_equipment.workcenter_id IN %s
AND (schedule_date, schedule_date + INTERVAL '1h' * duration) OVERLAPS (%s, %s)
AND (schedule_date, schedule_date + INT ERVAL '1h' * duration) OVERLAPS (%s, %s)
GROUP BY maintenance_equipment.workcenter_id;
"""
self.env.cr.execute(sql, [tuple(self.ids), fields.Datetime.to_string(start_datetime.astimezone()),

View File

@@ -1,3 +1,6 @@
import json
import requests
import logging
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models, SUPERUSER_ID, _
@@ -200,17 +203,20 @@ class ResMrpWorkOrder(models.Model):
# cnc程序获取
def fetchCNC(self):
res = [{'model_code': self.product_id.barcode, 'production_no': self.production_id.name,
'machine_tool_code': self.workcenter_id.machine_tool_id.code,
'material_code': self.env['sf.production.materials'].search(
[('id', '=', self.product_id.materials_id.id)]).materials_no,
'material_type_code': self.env['sf.materials.model'].search(
[('id', '=', self.product_id.materials_type_id.id)]).materials_no,
'embryo_long': self.product_id.bom_ids.bom_line_ids.product_id.long,
'embryo_height': self.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': self.product_id.bom_ids.bom_line_ids.product_id.width
# 'factory_code': self.env.user.company_id.partner_id.
}]
cnc = self.env['mrp.workorder'].search([('routing_type', '=', 'CNC加工')], limit=1)
res = {'model_code': cnc.product_id.barcode, 'production_no': self.production_id.name,
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
'material_code': cnc.env['sf.production.materials'].search(
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
'material_type_code': cnc.env['sf.materials.model'].search(
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
'machining_precision': cnc.product_id.model_machining_precision,
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.long,
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width
# 'factory_code': self.env.user.company_id.partner_id.
}
logging.info('res:%s' % res)
configsettings = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
url = '/api/intelligent_programming/create'