程序用刀异常提醒
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
from . import models
|
from . import models
|
||||||
|
from . import controllers
|
||||||
|
|||||||
1
sf_message/controllers/__init__.py
Normal file
1
sf_message/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import main
|
||||||
39
sf_message/controllers/main.py
Normal file
39
sf_message/controllers/main.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import logging
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo.addons.sf_mrs_connect.controllers.controllers import Sf_Mrs_Connect
|
||||||
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class Message_Sf_Mrs_Connect(Sf_Mrs_Connect):
|
||||||
|
|
||||||
|
@http.route('/api/cnc_processing/create', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_cnc_processing_create(self, **kw):
|
||||||
|
res = super(Message_Sf_Mrs_Connect, self).get_cnc_processing_create(**kw)
|
||||||
|
res = json.loads(res)
|
||||||
|
if res.get('production_ids'):
|
||||||
|
try:
|
||||||
|
productions = request.env['mrp.production'].sudo().search([('id', 'in', res.get('production_ids'))])
|
||||||
|
# 过滤programming_state为已编程,tool_state为2的制造订单
|
||||||
|
tool_state_valid_productions = productions.filtered(lambda x: x.programming_state == '已编程' and x.tool_state == '2')
|
||||||
|
if tool_state_valid_productions:
|
||||||
|
data = {
|
||||||
|
'name': tool_state_valid_productions[0].programming_no
|
||||||
|
}
|
||||||
|
# 请求cloud接口,发送微信消息推送
|
||||||
|
configsettings = request.env['res.config.settings'].sudo().get_values()
|
||||||
|
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||||
|
url = '/api/message/invalid_tool_state'
|
||||||
|
config_url = configsettings['sf_url'] + url
|
||||||
|
data['token'] = configsettings['token']
|
||||||
|
ret = requests.post(config_url, json=data, headers=config_header)
|
||||||
|
ret = ret.json()
|
||||||
|
_logger.info('无效用刀异常消息推送接口:%s' % ret)
|
||||||
|
except Exception as e:
|
||||||
|
_logger.info('无效用刀异常消息推送接口:%s' % e)
|
||||||
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@@ -6,4 +6,4 @@ from . import sf_message_cam_program
|
|||||||
from . import sf_message_functional_tool_assembly
|
from . import sf_message_functional_tool_assembly
|
||||||
from . import sf_message_purchase
|
from . import sf_message_purchase
|
||||||
from . import sf_message_workorder
|
from . import sf_message_workorder
|
||||||
from . import sf_message_functional_tool_dismantle
|
from . import sf_message_functional_tool_dismantle
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
pre_workorder.write(
|
pre_workorder.write(
|
||||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
|
res.update({
|
||||||
|
'production_ids': productions.ids
|
||||||
|
})
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
else:
|
else:
|
||||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||||
|
|||||||
Reference in New Issue
Block a user