From 56f1ba0f2578edafbe1715c367aa7084f151abd3 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 20 Sep 2024 14:24:50 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_hr/__manifest__.py | 3 ++- sf_hr/models/__init__.py | 1 + sf_hr/models/hr_employee.py | 6 ++++-- sf_hr/models/res_users.py | 12 ++++++++++++ sf_hr/views/res_users_view.xml | 20 ++++++++++++++++++++ sf_plan/static/description/计划.png | Bin 0 -> 673 bytes sf_plan/views/view.xml | 1 + 7 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 sf_hr/models/res_users.py create mode 100644 sf_hr/views/res_users_view.xml create mode 100644 sf_plan/static/description/计划.png diff --git a/sf_hr/__manifest__.py b/sf_hr/__manifest__.py index c0bd63ef..b3e21ab3 100644 --- a/sf_hr/__manifest__.py +++ b/sf_hr/__manifest__.py @@ -7,10 +7,11 @@ 'sequence': 1, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['hr'], + 'depends': ['base', 'hr'], 'data': [ 'views/hr_employee.xml', 'views/res_config_settings_views.xml', + 'views/res_users_view.xml', 'data/cron_data.xml', ], 'demo': [ diff --git a/sf_hr/models/__init__.py b/sf_hr/models/__init__.py index ffe76391..9744f0cc 100644 --- a/sf_hr/models/__init__.py +++ b/sf_hr/models/__init__.py @@ -2,3 +2,4 @@ from . import hr_employee from . import res_config_setting +from . import res_users diff --git a/sf_hr/models/hr_employee.py b/sf_hr/models/hr_employee.py index 8cf5595d..e9826f29 100644 --- a/sf_hr/models/hr_employee.py +++ b/sf_hr/models/hr_employee.py @@ -20,7 +20,9 @@ class JkmPracticeEmployee(models.Model): if result['employee_list']: for employee_info in result['employee_list']: if employee_info['work_email']: - self.sudo().search([('work_email', '=', employee_info['work_email'])]).write( - {'we_id': employee_info['we_id']}) + hr_employee = self.sudo().search([('work_email', '=', employee_info['work_email'])]) + hr_employee.write({'we_id': employee_info['we_id']}) + if hr_employee.user_id: + hr_employee.user_id.write({'we_employee_id': employee_info['we_id']}) else: logging.info('_employee_info_sync error:%s' % result['message']) diff --git a/sf_hr/models/res_users.py b/sf_hr/models/res_users.py new file mode 100644 index 00000000..392c297a --- /dev/null +++ b/sf_hr/models/res_users.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields, api + +import logging + +_logger = logging.getLogger(__name__) + + +class ResUsers(models.Model): + _inherit = 'res.users' + + we_employee_id = fields.Char(string=u'企业微信账号', default="") diff --git a/sf_hr/views/res_users_view.xml b/sf_hr/views/res_users_view.xml new file mode 100644 index 00000000..c65d8e46 --- /dev/null +++ b/sf_hr/views/res_users_view.xml @@ -0,0 +1,20 @@ + + + + + res.users.account.form + res.users + + + + + + + + + + + + + + diff --git a/sf_plan/static/description/计划.png b/sf_plan/static/description/计划.png new file mode 100644 index 0000000000000000000000000000000000000000..e4efa9f9988c818eccaf683366c07ecc4bfbcccf GIT binary patch literal 673 zcmV;S0$%-zP)Bal#n4ZG+?BP0*P9y$me_2O*}B075L5=p2m)GgP@V;u?vj}aY0B`6G6 zNX>QK=XdfuFg)I$*(bf{4?gU?o%zjt-~4_%^IOBVZNq~U7zdp`WBf?#`1?(8&px$} zAq9-m|AXH+%Q&?J5bY+P8{j(I9qfZ#!!-0v`1i1V#o;fhi%t_ND){UJDTjbO$nd-E z5CXjX--9Yxa_P&!~c|j>E4g%g@?m&}QyAdSd4sXCO;0722uay1?@%v@_4OpfCJK)4^ zDlg0?HIItSr9H#ecc%)54`%EaRrmGqY%Ou>;34ye?#Luea%=JLjH)1nx0sAsE zG6a_y&qfRXe!`lq~Pr5=31?o>QcOt+5p17*eA!q`y00000NkvXX Hu0mjf(0?lB literal 0 HcmV?d00001 diff --git a/sf_plan/views/view.xml b/sf_plan/views/view.xml index 10992f4a..09fa7b02 100644 --- a/sf_plan/views/view.xml +++ b/sf_plan/views/view.xml @@ -278,6 +278,7 @@ sequence="150" action="sf_production_plan_action" groups="sf_base.group_plan_dispatch" + web_icon="sf_plan,static/description/计划.png" /> From a6701a842e3b172e53db4e7815d44fd03e377abd Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 23 Sep 2024 11:55:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=88=80=E5=B0=96r=E8=A7=92=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/jikimo_bom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_tool_management/models/jikimo_bom.py b/sf_tool_management/models/jikimo_bom.py index 62138d77..b5caf495 100644 --- a/sf_tool_management/models/jikimo_bom.py +++ b/sf_tool_management/models/jikimo_bom.py @@ -89,7 +89,7 @@ class jikimo_bom(models.Model): ('cutting_tool_blade_diameter', '=', self.tool_inventory_id.diameter), # r角 - ('cutting_tool_blade_tip_working_size', '=', self.tool_inventory_id.angle)] + ('cutting_tool_blade_tip_r_size', '=', self.tool_inventory_id.angle)] if option.name == '刀杆': domain = ['&'] + domain + [ ("cutting_tool_cutter_arbor_diameter", "=", self.tool_inventory_id.diameter)] From e7e64720c6f4726aa3163c513a35c1143892f645 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 23 Sep 2024 11:55:28 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/__manifest__.py | 2 +- sf_message/data/bussiness_node.xml | 12 ++ sf_message/models/__init__.py | 1 + .../sf_message_functional_tool_assembly.py | 12 ++ .../sf_message_functional_tool_dismantle.py | 18 +++ sf_message/models/sf_message_stock_picking.py | 7 ++ sf_message/models/sf_message_template.py | 3 + sf_mrs_connect/controllers/controllers.py | 112 +++++++++--------- 8 files changed, 110 insertions(+), 57 deletions(-) create mode 100644 sf_message/models/sf_message_functional_tool_dismantle.py diff --git a/sf_message/__manifest__.py b/sf_message/__manifest__.py index cdfef4bd..0f032a6d 100644 --- a/sf_message/__manifest__.py +++ b/sf_message/__manifest__.py @@ -11,7 +11,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify'], + 'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify','stock'], 'data': [ 'data/bussiness_node.xml' ], diff --git a/sf_message/data/bussiness_node.xml b/sf_message/data/bussiness_node.xml index eeb7cbe7..a9c3dc62 100644 --- a/sf_message/data/bussiness_node.xml +++ b/sf_message/data/bussiness_node.xml @@ -10,5 +10,17 @@ 确认接单 sale.order + + 调拨入库 + stock.picking + + + 功能刀具组装 + sf.functional.tool.assembly + + + 功能刀具寿命到期 + sf.functional.tool.dismantle + \ No newline at end of file diff --git a/sf_message/models/__init__.py b/sf_message/models/__init__.py index b0c058fc..e84a0acd 100644 --- a/sf_message/models/__init__.py +++ b/sf_message/models/__init__.py @@ -6,3 +6,4 @@ from . import sf_message_cam_program from . import sf_message_functional_tool_assembly from . import sf_message_purchase from . import sf_message_workorder +from . import sf_message_functional_tool_dismantle \ No newline at end of file diff --git a/sf_message/models/sf_message_functional_tool_assembly.py b/sf_message/models/sf_message_functional_tool_assembly.py index 251af2cc..d4e05fc0 100644 --- a/sf_message/models/sf_message_functional_tool_assembly.py +++ b/sf_message/models/sf_message_functional_tool_assembly.py @@ -3,4 +3,16 @@ from odoo import models, fields, api, _ class SFMessagefunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' + _description = "刀具组装单" _inherit = ['sf.functional.tool.assembly', 'jikimo.message.dispatch'] + + @api.model_create_multi + def create(self, vals): + result = super(SFMessagefunctionalToolAssembly, self).create(vals) + is_cam = False + for obj in result: + if obj.loading_task_source == '0' and obj.assemble_status == '0': + is_cam = True + if is_cam: + self.add_queue('功能刀具组装') + return result diff --git a/sf_message/models/sf_message_functional_tool_dismantle.py b/sf_message/models/sf_message_functional_tool_dismantle.py new file mode 100644 index 00000000..dac3db28 --- /dev/null +++ b/sf_message/models/sf_message_functional_tool_dismantle.py @@ -0,0 +1,18 @@ +from odoo import models, api + + +class SFMessagefunctionalToolDismantle(models.Model): + _name = 'sf.functional.tool.dismantle' + _description = "刀具拆解单" + _inherit = ['sf.functional.tool.dismantle', 'jikimo.message.dispatch'] + + @api.model + def create(self, vals): + result = super(SFMessagefunctionalToolDismantle, self).create(vals) + is_dismantle = False + for obj in result: + if obj.dismantle_cause in ['寿命到期报废', '崩刀报废']and obj.state=='待拆解': + is_dismantle = True + if is_dismantle: + self.add_queue('功能刀具寿命到期') + return result diff --git a/sf_message/models/sf_message_stock_picking.py b/sf_message/models/sf_message_stock_picking.py index b090549e..d66008f9 100644 --- a/sf_message/models/sf_message_stock_picking.py +++ b/sf_message/models/sf_message_stock_picking.py @@ -3,4 +3,11 @@ from odoo import models, fields, api, _ class SFMessageStockPicking(models.Model): _name = 'stock.picking' + _description = "库存调拨" _inherit = ['stock.picking', 'jikimo.message.dispatch'] + + def button_validate(self): + res = super(SFMessageStockPicking, self).button_validate() + if self.location_id.name == '进货' and self.location_dest_id.name == '刀具房': + self.add_queue('调拨入库') + return res diff --git a/sf_message/models/sf_message_template.py b/sf_message/models/sf_message_template.py index 7380fbe6..5a37513c 100644 --- a/sf_message/models/sf_message_template.py +++ b/sf_message/models/sf_message_template.py @@ -9,4 +9,7 @@ class SfMessageTemplate(models.Model): def _get_message_model(self): res = super(SfMessageTemplate, self)._get_message_model() res.append("sale.order") + res.append("stock.picking") + res.append('sf.functional.tool.assembly') + res.append('sf.functional.tool.dismantle') return res diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index c5d1cd10..25736199 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller): request.env.ref("base.user_admin")).search(domain) if productions: # 拉取所有加工面的程序文件 - for r in ret['processing_panel'].split(','): - program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) - if os.path.exists(program_path_tmp_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) - download_state = request.env['sf.cnc.processing'].with_user( - request.env.ref("base.user_admin")).download_file_tmp( - ret['folder_name'], r) - if download_state is False: - res['status'] = -2 - res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - return json.JSONEncoder().encode(res) + # for r in ret['processing_panel'].split(','): + # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) + # if os.path.exists(program_path_tmp_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) + # download_state = request.env['sf.cnc.processing'].with_user( + # request.env.ref("base.user_admin")).download_file_tmp( + # ret['folder_name'], r) + # if download_state is False: + # res['status'] = -2 + # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) + # return json.JSONEncoder().encode(res) for production in productions: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] production._create_workorder(ret) productions.process_range_time() - else: - for panel in ret['processing_panel'].split(','): - # 查询状态为进行中且工序类型为CNC加工的工单 - cnc_workorder_has = production.workorder_ids.filtered( - lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', - 'rework', - 'cancel'] and ach.processing_panel == panel) - if cnc_workorder_has: - if cnc_workorder_has.cnc_ids: - cnc_workorder_has.cmm_ids.sudo().unlink() - cnc_workorder_has.cnc_ids.sudo().unlink() - request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( - production) - cnc_workorder_has.write( - {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), - 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) - for panel in ret['processing_panel'].split(','): - # 查询状态为进行中且工序类型为CNC加工的工单 - cnc_workorder = productions.workorder_ids.filtered( - lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' - 'cancel'] and ac.processing_panel == panel) - if cnc_workorder: - # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - # panel) - program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) - logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) - files_panel = os.listdir(program_path_tmp_panel) - if files_panel: - for file in files_panel: - file_extension = os.path.splitext(file)[1] - logging.info('file_extension:%s' % file_extension) - if file_extension.lower() == '.pdf': - panel_file_path = os.path.join(program_path_tmp_panel, file) - logging.info('panel_file_path:%s' % panel_file_path) - cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) - pre_workorder = productions.workorder_ids.filtered( - lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' - 'cancel'] and ap.processing_panel == panel) - if pre_workorder: - pre_workorder.write( - {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + # else: + # for panel in ret['processing_panel'].split(','): + # # 查询状态为进行中且工序类型为CNC加工的工单 + # cnc_workorder_has = production.workorder_ids.filtered( + # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', + # 'rework', + # 'cancel'] and ach.processing_panel == panel) + # if cnc_workorder_has: + # if cnc_workorder_has.cnc_ids: + # cnc_workorder_has.cmm_ids.sudo().unlink() + # cnc_workorder_has.cnc_ids.sudo().unlink() + # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( + # production) + # cnc_workorder_has.write( + # {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), + # 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) + # for panel in ret['processing_panel'].split(','): + # # 查询状态为进行中且工序类型为CNC加工的工单 + # cnc_workorder = productions.workorder_ids.filtered( + # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' + # 'cancel'] and ac.processing_panel == panel) + # if cnc_workorder: + # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', + # # panel) + # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) + # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) + # files_panel = os.listdir(program_path_tmp_panel) + # if files_panel: + # for file in files_panel: + # file_extension = os.path.splitext(file)[1] + # logging.info('file_extension:%s' % file_extension) + # if file_extension.lower() == '.pdf': + # panel_file_path = os.path.join(program_path_tmp_panel, file) + # logging.info('panel_file_path:%s' % panel_file_path) + # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + # pre_workorder = productions.workorder_ids.filtered( + # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' + # 'cancel'] and ap.processing_panel == panel) + # if pre_workorder: + # pre_workorder.write( + # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) productions.write({'programming_state': '已编程', 'work_state': '已编程'}) return json.JSONEncoder().encode(res) else: From b1a08be57b8c983938f4133e4ebcca3cc91712bb Mon Sep 17 00:00:00 2001 From: hujiaying Date: Mon, 23 Sep 2024 12:27:31 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=20bfm=E5=8A=A0=E5=B7=A5=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=AD=97=E6=AE=B5=20=EF=BC=8C=E5=BE=85?= =?UTF-8?q?=E5=8F=91=E8=B4=A7=E6=98=8E=E7=BB=86=E4=B8=AD=EF=BC=8C=E6=8E=A5?= =?UTF-8?q?=E5=8D=95=E6=97=A5=E6=9C=9F=E3=80=81=E5=8F=91=E8=B4=A7=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E9=A1=BA=E5=BA=8F=E6=94=B9=E5=8F=98=EF=BC=8C=E6=AC=A0?= =?UTF-8?q?=E5=8D=95=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=8F=91=E8=B4=A7?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E6=98=BE=E7=A4=BA=E5=8F=91=E8=B4=A7=E6=97=B6?= =?UTF-8?q?=E9=97=B4=20=E3=80=81=E6=9B=B4=E6=94=B9=E9=80=BE=E6=9C=9F?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_stock/models/stock_picking.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sf_stock/models/stock_picking.py b/sf_stock/models/stock_picking.py index 3a64f78c..a429db36 100644 --- a/sf_stock/models/stock_picking.py +++ b/sf_stock/models/stock_picking.py @@ -74,6 +74,8 @@ class StockPicking(models.Model): def send_to_bfm(self): skip_backorder = self.env.context.get('skip_backorder') + cancel_backorder_ids = self.env.context.get('picking_ids_not_to_backorder') + # 下发发货到bfm config = self.env['res.config.settings'].get_values() move_ids, move_line_ids = self.deal_move_ids(self.move_ids, self.move_line_ids) @@ -92,13 +94,13 @@ class StockPicking(models.Model): 'state': self.state, 'backorder_id': self.deal_send_backorder_id(self.backorder_id), 'backorder_ids': self.deal_send_backorder_id(self.backorder_ids), - 'cancel_backorder_ids': skip_backorder, + 'cancel_backorder_ids': True if skip_backorder and cancel_backorder_ids else False, # 没有欠单判断 'move_type': self.move_type, }, } url1 = config['bfm_url_new'] + '/api/stock/deliver_goods' json_str = json.dumps(data) - print('json_str', json_str) + logging.info('json_str= %s', json_str) r = requests.post(url1, json=data, data=None) if r.status_code == 200: result = json.loads(r.json()['result']) From 5af1953e04c5bb10028284180c417adb34ec765d Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 23 Sep 2024 13:20:31 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=9D=AF=E6=96=99=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/data/bussiness_node.xml | 4 ++++ sf_message/models/sf_message_purchase.py | 11 +++++++++++ sf_message/models/sf_message_template.py | 1 + 3 files changed, 16 insertions(+) diff --git a/sf_message/data/bussiness_node.xml b/sf_message/data/bussiness_node.xml index a9c3dc62..76f3fcb7 100644 --- a/sf_message/data/bussiness_node.xml +++ b/sf_message/data/bussiness_node.xml @@ -22,5 +22,9 @@ 功能刀具寿命到期 sf.functional.tool.dismantle + + 坯料采购提醒 + purchase.order + \ No newline at end of file diff --git a/sf_message/models/sf_message_purchase.py b/sf_message/models/sf_message_purchase.py index 073a7814..e9fe3956 100644 --- a/sf_message/models/sf_message_purchase.py +++ b/sf_message/models/sf_message_purchase.py @@ -1,6 +1,17 @@ +import logging from odoo import models, fields, api, _ class SFMessagePurchase(models.Model): _name = 'purchase.order' _inherit = ['purchase.order', 'jikimo.message.dispatch'] + + @api.model_create_multi + def create(self, vals_list): + res = super(SFMessagePurchase, self).create(vals_list) + if res: + try: + res.add_queue('坯料采购提醒') + except Exception as e: + logging.info('add_queue error:%s' % e) + return res diff --git a/sf_message/models/sf_message_template.py b/sf_message/models/sf_message_template.py index 5a37513c..957b0f58 100644 --- a/sf_message/models/sf_message_template.py +++ b/sf_message/models/sf_message_template.py @@ -12,4 +12,5 @@ class SfMessageTemplate(models.Model): res.append("stock.picking") res.append('sf.functional.tool.assembly') res.append('sf.functional.tool.dismantle') + res.append('purchase.order') return res From 8643c41193df53b04965716d83c34c62613aba3b Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 23 Sep 2024 13:33:05 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_mrs_connect/controllers/controllers.py | 112 +++++++++++----------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 25736199..c5d1cd10 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller): request.env.ref("base.user_admin")).search(domain) if productions: # 拉取所有加工面的程序文件 - # for r in ret['processing_panel'].split(','): - # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) - # if os.path.exists(program_path_tmp_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) - # download_state = request.env['sf.cnc.processing'].with_user( - # request.env.ref("base.user_admin")).download_file_tmp( - # ret['folder_name'], r) - # if download_state is False: - # res['status'] = -2 - # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - # return json.JSONEncoder().encode(res) + for r in ret['processing_panel'].split(','): + program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) + if os.path.exists(program_path_tmp_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) + download_state = request.env['sf.cnc.processing'].with_user( + request.env.ref("base.user_admin")).download_file_tmp( + ret['folder_name'], r) + if download_state is False: + res['status'] = -2 + res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) + return json.JSONEncoder().encode(res) for production in productions: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] production._create_workorder(ret) productions.process_range_time() - # else: - # for panel in ret['processing_panel'].split(','): - # # 查询状态为进行中且工序类型为CNC加工的工单 - # cnc_workorder_has = production.workorder_ids.filtered( - # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', - # 'rework', - # 'cancel'] and ach.processing_panel == panel) - # if cnc_workorder_has: - # if cnc_workorder_has.cnc_ids: - # cnc_workorder_has.cmm_ids.sudo().unlink() - # cnc_workorder_has.cnc_ids.sudo().unlink() - # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( - # production) - # cnc_workorder_has.write( - # {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), - # 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) - # for panel in ret['processing_panel'].split(','): - # # 查询状态为进行中且工序类型为CNC加工的工单 - # cnc_workorder = productions.workorder_ids.filtered( - # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' - # 'cancel'] and ac.processing_panel == panel) - # if cnc_workorder: - # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - # # panel) - # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) - # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) - # files_panel = os.listdir(program_path_tmp_panel) - # if files_panel: - # for file in files_panel: - # file_extension = os.path.splitext(file)[1] - # logging.info('file_extension:%s' % file_extension) - # if file_extension.lower() == '.pdf': - # panel_file_path = os.path.join(program_path_tmp_panel, file) - # logging.info('panel_file_path:%s' % panel_file_path) - # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) - # pre_workorder = productions.workorder_ids.filtered( - # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' - # 'cancel'] and ap.processing_panel == panel) - # if pre_workorder: - # pre_workorder.write( - # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + else: + for panel in ret['processing_panel'].split(','): + # 查询状态为进行中且工序类型为CNC加工的工单 + cnc_workorder_has = production.workorder_ids.filtered( + lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', + 'rework', + 'cancel'] and ach.processing_panel == panel) + if cnc_workorder_has: + if cnc_workorder_has.cnc_ids: + cnc_workorder_has.cmm_ids.sudo().unlink() + cnc_workorder_has.cnc_ids.sudo().unlink() + request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( + production) + cnc_workorder_has.write( + {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), + 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) + for panel in ret['processing_panel'].split(','): + # 查询状态为进行中且工序类型为CNC加工的工单 + cnc_workorder = productions.workorder_ids.filtered( + lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' + 'cancel'] and ac.processing_panel == panel) + if cnc_workorder: + # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', + # panel) + program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) + logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) + files_panel = os.listdir(program_path_tmp_panel) + if files_panel: + for file in files_panel: + file_extension = os.path.splitext(file)[1] + logging.info('file_extension:%s' % file_extension) + if file_extension.lower() == '.pdf': + panel_file_path = os.path.join(program_path_tmp_panel, file) + logging.info('panel_file_path:%s' % panel_file_path) + cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + pre_workorder = productions.workorder_ids.filtered( + lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' + 'cancel'] and ap.processing_panel == panel) + if pre_workorder: + pre_workorder.write( + {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) productions.write({'programming_state': '已编程', 'work_state': '已编程'}) return json.JSONEncoder().encode(res) else: