diff --git a/sf_bf_connect/controllers/controllers.py b/sf_bf_connect/controllers/controllers.py
index 8c901610..607aa5c2 100644
--- a/sf_bf_connect/controllers/controllers.py
+++ b/sf_bf_connect/controllers/controllers.py
@@ -111,11 +111,12 @@ class Sf_Bf_Connect(http.Controller):
res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配'
request.cr.rollback()
return json.JSONEncoder().encode(res)
- # 产品配置bom
- product_bom_purchase = request.env['mrp.bom'].with_user(
- request.env.ref("base.user_admin")).bom_create(product, 'normal', False)
- product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has(
- purchase_embryo)
+ else:
+ # 产品配置bom
+ product_bom_purchase = request.env['mrp.bom'].with_user(
+ request.env.ref("base.user_admin")).bom_create(product, 'normal', False)
+ product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has(
+ purchase_embryo)
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
i += 1
res['factory_order_no'] = order_id.name
diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py
index 80ae21e7..2a5305f5 100644
--- a/sf_manufacturing/controllers/controllers.py
+++ b/sf_manufacturing/controllers/controllers.py
@@ -511,7 +511,6 @@ class Manufacturing_Connect(http.Controller):
rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code)
domain = [
- ('feeder_station_start_id.name', '=', ret['DeviceId']),
('workorder_id.rfid_code', '=', rfid_code),
('status', '=', '待下发'),
('type', '=', '下产线')
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index 862397a9..5e575ef7 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -154,7 +154,7 @@ class MrpProduction(models.Model):
production.maintenance_count = len(production.request_ids)
# cnc程序获取
- def fetchCNC(self, production_names):
+ def fetchCNC(self):
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
quick_order = self.env['quick.easy.order'].search(
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
@@ -166,25 +166,26 @@ class MrpProduction(models.Model):
if quick_order:
programme_way = 'manual operation'
try:
- res = {'model_code': cnc.product_id.name,
- 'production_no': production_names,
- 'machine_tool_code': "",
- 'material_code': self.env['sf.production.materials'].search(
- [('id', '=', cnc.product_id.materials_id.id)]).materials_no,
- 'material_type_code': self.env['sf.materials.model'].search(
- [('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
- 'machining_processing_panel': cnc.product_id.model_processing_panel,
- 'machining_precision': cnc.product_id.model_machining_precision,
- 'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
- '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,
- 'user': cnc.env.user.name,
- 'programme_way': programme_way,
- 'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
- cnc.product_id.model_file).decode('utf-8')
- }
+ res = {
+ 'production_no': cnc.name,
+ 'machine_tool_code': '',
+ 'model_code': cnc.product_id.model_code,
+ 'material_code': self.env['sf.production.materials'].search(
+ [('id', '=', cnc.product_id.materials_id.id)]).materials_no,
+ 'material_type_code': self.env['sf.materials.model'].search(
+ [('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
+ 'machining_processing_panel': cnc.product_id.model_processing_panel,
+ 'machining_precision': cnc.product_id.model_machining_precision,
+ 'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
+ '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,
+ 'user': cnc.env.user.name,
+ 'programme_way': programme_way,
+ 'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
+ cnc.product_id.model_file).decode('utf-8')
+ }
# 打印出除了 model_file 之外的所有键值对
for key, value in res.items():
if key != 'model_file':
@@ -266,15 +267,15 @@ class MrpProduction(models.Model):
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
def _create_workorder3(self):
- production_names = [production.name for production in self if production.product_id.categ_id.type == '成品']
- programming_no = None
- product_first = None
+ # production_names = [production.name for production in self if production.product_id.categ_id.type == '成品']
+ # programming_no = None
+ # product_first = None
for production in self:
if not production.bom_id or not production.product_id:
continue
workorders_values = []
- if product_first is None:
- product_first = production.product_id
+ # if product_first is None:
+ # product_first = production.product_id
product_qty = production.product_uom_id._compute_quantity(production.product_qty,
production.bom_id.product_uom_id)
@@ -299,13 +300,15 @@ class MrpProduction(models.Model):
'state': 'pending',
}]
if production.product_id.categ_id.type == '成品':
- if programming_no is None:
- production.fetchCNC(production_names)
- programming_no = production.programming_no
- else:
- if production.product_id == product_first:
- if not production.programming_no:
- production.write({'programming_no': programming_no, 'programming_state': '编程中'})
+ production.fetchCNC()
+ # 第二期同一个产品多个制造订单对应一个编程单和模型库
+ # if programming_no is None:
+ # production.fetchCNC(production_names)
+ # programming_no = production.programming_no
+ # else:
+ # if production.product_id == product_first:
+ # if not production.programming_no:
+ # production.write({'programming_no': programming_no, 'programming_state': '编程中'})
# 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 04b59430..cdc190c2 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -827,8 +827,6 @@ class ResMrpWorkOrder(models.Model):
raise UserError("请对前置三元检测定位参数进行计算定位")
if not record.rfid_code:
raise UserError("请扫RFID码进行绑定")
- record.workpiece_delivery_ids[0].write({'status': '待下发'})
-
if record.routing_type == '解除装夹':
'''
记录结束时间
@@ -895,13 +893,17 @@ class ResMrpWorkOrder(models.Model):
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
def get_detection_file(self, workorder, reportPath):
- if reportPath.startswith('/'):
- reportPath = reportPath[4:]
- serverdir = os.path.join('/tmp', reportPath)
+ # if reportPath.startswith('/'):
+ # reportPath = reportPath[4:]
+ # serverdir = os.path.join('/tmp', reportPath)
+ serverdir = '/tmp' + reportPath
logging.info('get_detection_file-serverdir:%s' % serverdir)
serverdir_prefix = os.path.dirname(serverdir)
+ logging.info('serverdir_prefix-serverdir:%s' % serverdir_prefix)
for root, dirs, files in os.walk(serverdir_prefix):
for filename in files:
+ logging.info('filename:%s' % filename)
+ logging.info('reportPath:%s' % os.path.basename(reportPath))
if filename == os.path.basename(reportPath):
report_file_path = os.path.join(root, filename)
logging.info('get_detection_file-report_file_path:%s' % report_file_path)
@@ -1290,7 +1292,7 @@ class WorkPieceDelivery(models.Model):
'default_type': production_type,
}}
else:
- if self.type == '运送空料架':
+ if production_type == '运送空料架':
raise UserError("您所选择的【任务路线】的【终点接驳站】已占用,请在该接驳站空闲时进行配送")
else:
raise UserError(
@@ -1330,11 +1332,13 @@ class WorkPieceDelivery(models.Model):
if route_id is None:
route_id = item.route_id.id
if feeder_station_start is None:
- feeder_station_start = item.feeder_station_start_id.name
+ feeder_station_start = item.feeder_station_start_id
if feeder_station_destination is None:
- feeder_station_destination = item.feeder_station_destination_id.name
+ feeder_station_destination = item.feeder_station_destination_id
if item.type in ['上产线', '下产线']:
item.route_id = route_id
+ item.feeder_station_start_id = feeder_station_start.id
+ item.feeder_station_destination_id = feeder_station_destination.id
delivery_Arr.append(item.name)
else:
self = self.create(
@@ -1346,12 +1350,12 @@ class WorkPieceDelivery(models.Model):
delivery_str = ','.join(map(str, delivery_Arr))
if feeder_station_start is not None:
positionCode_Arr.append({
- 'positionCode': feeder_station_start,
+ 'positionCode': feeder_station_start.name,
'code': '00'
})
if feeder_station_destination is not None:
positionCode_Arr.append({
- 'positionCode': feeder_station_destination,
+ 'positionCode': feeder_station_destination.name,
'code': '00'
})
res = {'reqCode': delivery_str, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index 8c9cb3db..08c37d32 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -608,7 +608,7 @@
-
+
diff --git a/sf_mrs_connect/models/ftp_operate.py b/sf_mrs_connect/models/ftp_operate.py
index a1689825..3a09a305 100644
--- a/sf_mrs_connect/models/ftp_operate.py
+++ b/sf_mrs_connect/models/ftp_operate.py
@@ -24,6 +24,7 @@ class FtpController():
def file_exists(self, path):
# 检查文件是否存在于FTP服务器上
try:
+ logging.info("dirname:%s" % os.path.dirname(path))
self.ftp.cwd(os.path.dirname(path))
files = self.ftp.nlst()
return os.path.basename(path) in files
@@ -31,6 +32,11 @@ class FtpController():
logging.error(f"Error checking file: {e}")
return False
+ # # 检测字符串的编码
+ # def detect_encoding(self, s):
+ # result = chardet.detect(s)
+ # return result['encoding']
+
# 下载目录下的文件
def download_file_tree(self, target_dir, serverdir):
if not os.path.exists(serverdir):
@@ -40,17 +46,13 @@ class FtpController():
logging.info('目录:%s' % target_dir)
target_dir1 = target_dir.split('/')
logging.info('目录1:%s' % target_dir1[1])
- self.ftp.cwd('NC')
- self.ftp.cwd('XT_WH_MO_00164')
- self.ftp.cwd('return')
- self.ftp.cwd('R')
- # 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]) # 切换工作路径
+ 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:
@@ -88,6 +90,9 @@ class FtpController():
return 1
except Exception:
return 0
+ finally:
+ self.ftp.quit()
+ logging.info("ftp已关闭")
# 下载指定目录下的指定文件
def download_file(self, serverfile, remotefile):
diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py
index 60618f1d..b2f04edd 100644
--- a/sf_plan/models/custom_plan.py
+++ b/sf_plan/models/custom_plan.py
@@ -229,6 +229,11 @@ class sf_production_plan(models.Model):
record.env['mrp.production'].sudo().browse(i).schedule_state = '已排'
# record.production_id.date_planned_start = record.date_planned_start
# record.production_id.date_planned_finished = record.date_planned_finished
+ record.production_id.production_line_id = record.production_line_id.id
+ record.production_id.workorder_ids.filtered(
+ lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
+ {'production_line_id': record.production_line_id.id,
+ 'plan_start_processing_time': record.date_planned_start})
else:
raise ValidationError("未找到工单")
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)