Commit bbf327f5 by guibin

将/roke/workstation/plant/tree接口设置成无需登录

parent d9373859
...@@ -22,3 +22,77 @@ class RokeMesThreeColourLight(http.Controller): ...@@ -22,3 +22,77 @@ class RokeMesThreeColourLight(http.Controller):
data = {"code": 1, "message": "请求通过", "data": {"factory_code": factory_code}} data = {"code": 1, "message": "请求通过", "data": {"factory_code": factory_code}}
template = env.get_template('equipment_status_qdry.html') template = env.get_template('equipment_status_qdry.html')
return template.render(data) return template.render(data)
@http.route('/roke/workstation/plant/tree', type='json', auth='none', csrf=False, cors="*")
def get_roke_workstation_plant(self):
_self = http.request
no_icon = _self.jsonrequest.get("no_icon", False)
data = []
workshop_ids = http.request.env(user=SUPERUSER_ID)['roke.workshop'].search([
("plant_id", "=", False)
], order="name asc")
if len(workshop_ids) > 0:
data.append({
"id": 0,
"name": "未分配至车间",
"type": "plant",
"file_list": [],
"workshops": [
{
"id": workshop_id.id,
"name": workshop_id.name or "",
"type": "workshop",
"workshop_icon": workshop_id.workshop_icon or "",
"classes_id": workshop_id.classes_id.id,
"classes_name": workshop_id.classes_id.name or "",
"center_count": len(workshop_id.center_ids),
"file_list": [{
"name": attachment.name,
"file_type": attachment.mimetype,
"data": f"data:{attachment.mimetype};base64,{attachment.datas.decode('utf-8')}" if
not no_icon else "",
"url": self._get_attachment_file_url(attachment)
} for attachment in workshop_id.attachment_ids]
} for workshop_id in workshop_ids
]
})
plant_ids = http.request.env(user=SUPERUSER_ID)['roke.plant'].search([
], order="name asc")
for plant_id in plant_ids:
# print("plant_id", plant_id.company_ids)
data.append({
"id": plant_id.id,
"name": plant_id.name or "未分配至车间",
"type": "plant",
"file_list": [{
"name": attachment.name,
"file_type": attachment.mimetype,
"data": f"data:{attachment.mimetype};base64,{attachment.datas.decode('utf-8')}" if not no_icon
else "",
"url": self._get_attachment_file_url(attachment)
} for attachment in plant_id.attachment_ids],
"workshops": [
{
"id": workshop_id.id,
"name": workshop_id.name or "",
"type": "workshop",
"workshop_icon": workshop_id.workshop_icon or "",
"classes_id": workshop_id.classes_id.id,
"classes_name": workshop_id.classes_id.name or "",
"center_count": len(workshop_id.center_ids),
"file_list": [{
"name": attachment.name,
"file_type": attachment.mimetype,
"data": f"data:{attachment.mimetype};base64,{attachment.datas.decode('utf-8')}" if
not no_icon else "",
"url": self._get_attachment_file_url(attachment)
} for attachment in workshop_id.attachment_ids]
} for workshop_id in plant_id.workshop_ids
]
})
return {"code": 0, "message": "获取车间列表成功", "data": data}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment