1.ftp文件路径修改为:/NC/以下
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import json
|
||||
from datetime import datetime
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
@@ -438,6 +439,7 @@ class Manufacturing_Connect(http.Controller):
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已上产线'})
|
||||
wd.write({'production_line_state': '已上产线'})
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
|
||||
else:
|
||||
@@ -471,7 +473,21 @@ class Manufacturing_Connect(http.Controller):
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
workpiece_delivery_off=request.env['sf.workpiece.delivery'].create({
|
||||
'production_id': wd.production_id.id,
|
||||
'feeder_station_start': ret['DeviceId'],
|
||||
'feeder_station_destination': '',
|
||||
'workorder_id': workpiece_delivery.workorder_id,
|
||||
'workpiece_code': workpiece_delivery.workpiece_code,
|
||||
'production_line_id': workpiece_delivery.production_line_id,
|
||||
'task_delivery_time': datetime.now(),
|
||||
'production_line_state': '已下产线'
|
||||
})
|
||||
wd.production_id.write({'production_line_state': '已下产线'})
|
||||
logging.info('开始向agv下发下产线任务')
|
||||
workpiece_delivery_off._delivery_avg()
|
||||
logging.info('agv下发下产线任务已配送')
|
||||
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
|
||||
else:
|
||||
|
||||
@@ -146,7 +146,7 @@ class MrpProduction(models.Model):
|
||||
'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,
|
||||
'order_no': cnc.origin,
|
||||
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
|
||||
'model_order_no': '-'.join(cnc.product_id.default_code.split('-')[:4]),
|
||||
'user': cnc.env.user.name,
|
||||
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
cnc.product_id.model_file).decode('utf-8')
|
||||
|
||||
@@ -241,16 +241,19 @@ class ResMrpWorkOrder(models.Model):
|
||||
# if not item.workpiece_code:
|
||||
# raise UserError('请对【同运工件】进行扫描')
|
||||
else:
|
||||
if item.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_workorder_id': self.id,
|
||||
}}
|
||||
if self.cnc_program_down_state == '已下发':
|
||||
if item.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_workorder_id': self.id,
|
||||
}}
|
||||
else:
|
||||
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
|
||||
|
||||
# 拼接工单对象属性值
|
||||
def json_workorder_str(self, k, production, route):
|
||||
@@ -654,7 +657,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
production_no_ftp = reportpath.split('/')
|
||||
production_no = workorder.production_id.name.replace('/', '_')
|
||||
# ftp地址
|
||||
remotepath = os.path.join('/', production_no_ftp[1], 'detection')
|
||||
remotepath = os.path.join('/NC/', production_no_ftp[1], 'detection')
|
||||
logging.info('ftp地址:%s' % remotepath)
|
||||
if reportpath.find(production_no) != -1:
|
||||
# 服务器内临时地址
|
||||
@@ -772,8 +775,8 @@ class CNCprocessing(models.Model):
|
||||
|
||||
# 将FTP的nc文件下载到临时目录
|
||||
def download_file_tmp(self, production_no, processing_panel):
|
||||
remotepath = os.path.join('/', production_no, 'return', processing_panel)
|
||||
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||
remotepath = os.path.join('/NC/', production_no, 'return', processing_panel)
|
||||
serverdir = os.pat.join('/tmp', production_no, 'return', processing_panel)
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
|
||||
ftp_resconfig['ftp_password'])
|
||||
@@ -956,26 +959,39 @@ class WorkPieceDelivery(models.Model):
|
||||
status = fields.Selection(
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
|
||||
default='待下发')
|
||||
production_line_state = fields.Selection(
|
||||
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||
string='上/下产线', default='待上产线')
|
||||
cnc_program_down_state = fields.Selection([('待下发', '待下发'), ('已下发', '已下发')],
|
||||
string='CNC程序下发状态', default='待下发')
|
||||
|
||||
# 工件配送
|
||||
def button_delivery(self):
|
||||
if self.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_id': self.id,
|
||||
}}
|
||||
if self.cnc_program_down_state == '待下发':
|
||||
if self.status == '待下发':
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_id': self.id,
|
||||
}}
|
||||
else:
|
||||
raise UserError('状态为【待下发】的工件记录可进行配送')
|
||||
else:
|
||||
raise UserError('状态为【待下发】的工件记录可进行配送')
|
||||
raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送"))
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
agv_site = self.env['res.agv.site'].search([])
|
||||
site_production_line = False
|
||||
if self.production_line_state == '待上产线':
|
||||
site_production_line = [('production_line_status', '=', '已上产线')]
|
||||
elif self.production_line_state == '已下产线':
|
||||
site_production_line = [('production_line_status', '=', '已下产线')]
|
||||
agv_site = self.env['res.agv.site'].search(site_production_line, order="number asc")
|
||||
positionCode_Arr = []
|
||||
if agv_site:
|
||||
for item in agv_site:
|
||||
@@ -984,14 +1000,16 @@ class WorkPieceDelivery(models.Model):
|
||||
'code': item.type
|
||||
})
|
||||
res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
|
||||
'taskTyp': config['task_type_no'], 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
|
||||
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
|
||||
'positionCodePath': positionCode_Arr,
|
||||
'podCode': '',
|
||||
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
|
||||
'data': ''}
|
||||
try:
|
||||
config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
|
||||
logging.info('AGV请求路径:%s' % config['agv_rcs_url'])
|
||||
logging.info('AGV-json:%s' % res)
|
||||
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
ret = requests.post((config['agv_rcs_url']), json=res, headers=headers)
|
||||
ret = ret.json()
|
||||
|
||||
@@ -6,8 +6,8 @@ import os
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.modules import get_resource_path
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -419,6 +419,7 @@
|
||||
<field name="workpiece_code"/>
|
||||
<field name="feeder_station_start" force_save="1"/>
|
||||
<field name="feeder_station_destination" force_save="1"/>
|
||||
<field name="cnc_program_down_state" readonly="1"/>
|
||||
<field name="production_line_id"/>
|
||||
<field name="task_delivery_time" readonly="1"/>
|
||||
<field name="task_completion_time" readonly="1"/>
|
||||
@@ -560,6 +561,7 @@
|
||||
<field name="production_line_id"/>
|
||||
<field name="feeder_station_start"/>
|
||||
<field name="feeder_station_destination"/>
|
||||
<field name="cnc_program_down_state"/>
|
||||
<field name="task_delivery_time"/>
|
||||
<field name="task_completion_time"/>
|
||||
<field name="delivery_duration" widget="float_time"/>
|
||||
@@ -584,6 +586,9 @@
|
||||
<searchpanel>
|
||||
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
|
||||
<field name="status" icon="fa-building" enable_counters="1"/>
|
||||
<field name="production_line_state" icon="fa-building" enable_counters="1"/>
|
||||
<field name="cnc_program_down_state" icon="fa-building" enable_counters="1"/>
|
||||
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
@@ -27,8 +27,16 @@ class FtpController():
|
||||
os.makedirs(serverdir)
|
||||
try:
|
||||
logging.info("进入FTP目录 ")
|
||||
self.ftp.cwd(target_dir) # 切换工作路径
|
||||
logging.info('FTP目录:%s' % target_dir)
|
||||
logging.info('目录:%s' % target_dir)
|
||||
target_dir1 = target_dir.split('/')
|
||||
logging.info('目录1:%s' % target_dir1[1])
|
||||
self.ftp.cwd(target_dir1[1]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[2])
|
||||
self.ftp.cwd(target_dir1[2]) # 切换工作路径
|
||||
logging.info('目录3:%s' % target_dir1[3])
|
||||
self.ftp.cwd(target_dir1[3]) # 切换工作路径
|
||||
logging.info('目录4:%s' % target_dir1[4])
|
||||
self.ftp.cwd(target_dir1[4]) # 切换工作路径
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录文件:%s' % remotenames)
|
||||
for file in remotenames:
|
||||
@@ -38,6 +46,9 @@ class FtpController():
|
||||
return 1
|
||||
except Exception:
|
||||
return 0
|
||||
finally:
|
||||
self.ftp.quit()
|
||||
logging.info("ftp已关闭")
|
||||
|
||||
# 下载目录下的检测文件
|
||||
def download_reportfile_tree(self, target_dir, serverdir, reportpath):
|
||||
@@ -51,6 +62,8 @@ class FtpController():
|
||||
self.ftp.cwd(target_dir1[1]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[2])
|
||||
self.ftp.cwd(target_dir1[2]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[3])
|
||||
self.ftp.cwd(target_dir1[3]) # 切换工作路径
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录检测报告文件:%s' % remotenames)
|
||||
for filename in remotenames:
|
||||
|
||||
@@ -140,5 +140,20 @@ class ResAgvSite(models.Model):
|
||||
_name = 'res.agv.site'
|
||||
_description = 'agv站点'
|
||||
|
||||
number = fields.Integer('编号')
|
||||
type = fields.Selection([('00', '位置编号'), ('01', '库区编号'), ('02', '货架编号')], '类型')
|
||||
content = fields.Char('内容')
|
||||
site_prop = fields.Selection([('上产线', '上产线'), ('下产线', '下产线')], '属性')
|
||||
state_status = fields.Selection([('占用', '占用'), ('空闲', '空闲')], '状态')
|
||||
# remark = fields.Char
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals):
|
||||
# if vals.get('number', 'new') == 'new':
|
||||
# vals['number'] = self.env['ir.sequence'].next_by_code('res.agv.site') or '/'
|
||||
# return super(ResAgvSite, self).create(vals)
|
||||
|
||||
def unlink(self):
|
||||
for item in self:
|
||||
item.active == True
|
||||
|
||||
@@ -2375,6 +2375,7 @@ class CuttingToolBasicParameters(models.Model):
|
||||
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
logging.info(result)
|
||||
if result['status'] == 1:
|
||||
if 'basic_parameters_integral_tool' in result['cutting_tool_basic_parameters_all_list']:
|
||||
if result['cutting_tool_basic_parameters_all_list']['basic_parameters_integral_tool']:
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
<field name="model">res.agv.site</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="number"/>
|
||||
<field name="type"/>
|
||||
<field name="content"/>
|
||||
<field name="state_status"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -8,8 +8,8 @@ from datetime import datetime
|
||||
import requests
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
Reference in New Issue
Block a user