Accept Merge Request #2127: (feature/6694 -> develop)
Merge Request: 增加零件图号 Created By: @胡尧 Accepted By: @胡尧 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2127?initial=true
This commit is contained in:
@@ -195,10 +195,18 @@ class PrintingUtils(models.AbstractModel):
|
|||||||
text_y = margin + 20 # 文字位置靠近底部
|
text_y = margin + 20 # 文字位置靠近底部
|
||||||
c.drawString(text_x, text_y, text)
|
c.drawString(text_x, text_y, text)
|
||||||
|
|
||||||
|
# 设置字体
|
||||||
|
if font_found:
|
||||||
|
c.setFont('SimSun', 12) # 增大字体大小到14pt
|
||||||
|
else:
|
||||||
|
# 如果没有找到中文字体,使用默认字体
|
||||||
|
c.setFont('Helvetica', 120)
|
||||||
|
logging.warning("未找到中文字体,将使用默认字体")
|
||||||
|
|
||||||
if buttom_text:
|
if buttom_text:
|
||||||
# 在下方中间添加文字
|
# 在下方中间添加文字
|
||||||
text = button_text
|
text = buttom_text
|
||||||
text_width = c.stringWidth(text, "SimSun" if font_found else "Helvetica", 10) # 准确计算文字宽度
|
text_width = c.stringWidth(text, "SimSun" if font_found else "Helvetica", 12) # 准确计算文字宽度
|
||||||
text_x = (page_width - text_width) / 2 # 文字居中对齐
|
text_x = (page_width - text_width) / 2 # 文字居中对齐
|
||||||
text_y = margin + 20 # 文字位置靠近底部
|
text_y = margin + 20 # 文字位置靠近底部
|
||||||
c.drawString(text_x, text_y, text)
|
c.drawString(text_x, text_y, text)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
res = {'status': 1, 'message': '成功'}
|
res = {'status': 1, 'message': '成功'}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
model_id = None
|
model_id = None
|
||||||
|
part_number = None
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
ret = json.loads(ret['result'])
|
||||||
logging.info('下发编程单:%s' % ret)
|
logging.info('下发编程单:%s' % ret)
|
||||||
@@ -59,7 +60,6 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
for production in productions:
|
for production in productions:
|
||||||
model_id = production.product_id.model_id # 一个编程单的制造订单对应同一个模型
|
|
||||||
production.write({'programming_state': '已编程', 'work_state': '已编程', 'is_rework': False})
|
production.write({'programming_state': '已编程', 'work_state': '已编程', 'is_rework': False})
|
||||||
for panel in ret['processing_panel'].split(','):
|
for panel in ret['processing_panel'].split(','):
|
||||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
@@ -76,6 +76,10 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
cnc_workorder_has.write(
|
cnc_workorder_has.write(
|
||||||
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
{'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)})
|
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
|
||||||
|
|
||||||
|
# 一个编程单的制造订单对应同一个模型
|
||||||
|
model_id = productions[0].product_id.model_id
|
||||||
|
part_number = productions[0].product_id.part_number
|
||||||
for panel in ret['processing_panel'].split(','):
|
for panel in ret['processing_panel'].split(','):
|
||||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
cnc_workorder = productions.workorder_ids.filtered(
|
cnc_workorder = productions.workorder_ids.filtered(
|
||||||
@@ -95,7 +99,12 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
logging.info('panel_file_path:%s' % panel_file_path)
|
logging.info('panel_file_path:%s' % panel_file_path)
|
||||||
|
|
||||||
# 向编程单中添加二维码
|
# 向编程单中添加二维码
|
||||||
request.env['printing.utils'].add_qr_code_to_pdf(panel_file_path, model_id, "模型ID:%s" % model_id)
|
request.env['printing.utils'].add_qr_code_to_pdf(
|
||||||
|
panel_file_path,
|
||||||
|
model_id,
|
||||||
|
"模型ID:%s" % model_id,
|
||||||
|
"零件图号:%s" % part_number if part_number else None
|
||||||
|
)
|
||||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
pre_workorder = productions.workorder_ids.filtered(
|
pre_workorder = productions.workorder_ids.filtered(
|
||||||
lambda ap: ap.routing_type in ['装夹预调', '人工线下加工'] and ap.state not in ['done', 'rework'
|
lambda ap: ap.routing_type in ['装夹预调', '人工线下加工'] and ap.state not in ['done', 'rework'
|
||||||
|
|||||||
Reference in New Issue
Block a user