Commit 2f5e2fa5 by wangkangjie

Merge branch 'master' of https://git.rokedata.com/dws/dwsproject

parents 7bd63c2e 94d45005
...@@ -207,3 +207,27 @@ class ResMesBigScreen(http.Controller): ...@@ -207,3 +207,27 @@ class ResMesBigScreen(http.Controller):
"total": total, "total": total,
"abnormal_alarm_list": abnormal_alarm_list "abnormal_alarm_list": abnormal_alarm_list
} }
@http.route('/roke/tht/utilization_rate_top_5', type='json', auth='none', methods=['POST'], csrf=False,cors="*")
def get_oee_top5(self):
try:
url = "https://dws-platform.xbg.rokeris.com/dev-api/public/device_efficiency/series_utilization_rate_top_5"
eq_ids = http.request.env["roke.mes.equipment"].sudo().search([('code',"!=",'')])
query_data = [{"device_name": eq_id.name,"device_code": eq_id.code} for eq_id in eq_ids]
res = requests.post(url, data=json.dumps({
"device_code_list": query_data,
"plan_time_list":{}
}), headers=headers)
if res.status_code != 200:
return {"code": 1, "message": "获取数据失败", "data": None}
res = res.json()
data = res.get("data", {})
device_data = data.get("device_data", [])
return_data = [{"device_name": item.get("device_name"),
"today_utilization_rate": str(item.get("today_utilization_rate",0)) + "%",}
for item in device_data]
date =fields.Date.today().strftime("%Y-%m-%d")
return {"code": "success", "message": "", "data": return_data,"date": date}
except Exception as e:
return {"code": "error", "message": f"获取数据失败:{str(e)}", "data": None,"date": date}
...@@ -233,6 +233,7 @@ ...@@ -233,6 +233,7 @@
if (this.getUrlSearch("factory_code")) { if (this.getUrlSearch("factory_code")) {
this.factoryCode = this.getUrlSearch("factory_code"); //截取url后面的参数 this.factoryCode = this.getUrlSearch("factory_code"); //截取url后面的参数
} }
// this.factoryCode = "66c6bd8c-fd58-11ef-9692-00163e04c506"
this.initCurrentTimeFn() this.initCurrentTimeFn()
}, },
computed: { computed: {
...@@ -529,12 +530,12 @@ ...@@ -529,12 +530,12 @@
this.allEquipmentData.forEach(function (equip) { this.allEquipmentData.forEach(function (equip) {
codeToSeqMap[equip.code] = equip.sequence; codeToSeqMap[equip.code] = equip.sequence;
}); });
// 获取当前车间下的设备 code 列表 // 获取当前车间下的设备 code 列表
var validCodes = this.allEquipmentData var validCodes = this.allEquipmentData.filter(function (e) {
.filter(function (e) { return !this.selectedWorkshop || e.plant_name === this.selectedWorkshop; }.bind(this)) return !this.selectedWorkshop || e.plant_name === this.selectedWorkshop;
.map(function (e) { return e.code; }); }.bind(this)).map(function (e) {
return e.code;
});
// 过滤掉不属于当前车间的设备 // 过滤掉不属于当前车间的设备
var filteredDevices = deviceStateData.filter(function (d) { var filteredDevices = deviceStateData.filter(function (d) {
return !this.selectedWorkshop || validCodes.includes(d.code); return !this.selectedWorkshop || validCodes.includes(d.code);
...@@ -545,7 +546,7 @@ ...@@ -545,7 +546,7 @@
}); });
// 将API返回的数据转换为页面所需的格式 // 将API返回的数据转换为页面所需的格式
this.deviceList = filteredDevices.map(function (device) { var deviceList = filteredDevices.map(function (device, index) {
// 根据API返回的状态确定前端显示的状态 // 根据API返回的状态确定前端显示的状态
var status = "off"; var status = "off";
if (device.state === "green") { if (device.state === "green") {
...@@ -581,10 +582,10 @@ ...@@ -581,10 +582,10 @@
var deviceName = device.name || device.code // 默认使用API返回的名称或编码 var deviceName = device.name || device.code // 默认使用API返回的名称或编码
// 在所有设备列表中查找匹配的设备 // 在所有设备列表中查找匹配的设备
if (this.allEquipmentData && this.allEquipmentData.length > 0) { if (this.allEquipmentData && this.allEquipmentData.length > 0) {
var matchedDevice = this.allEquipmentData.find(function (equip) { return equip.code === device.code; }); var matchedDevice = this.allEquipmentData.find(function (equip) { return equip.code === device.code; })
// 如果找到匹配的设备,使用其名称 // 如果找到匹配的设备,使用其名称
if (matchedDevice && matchedDevice.name) { if (matchedDevice && matchedDevice.name) {
deviceName = device.name ? matchedDevice.name : device.code deviceName = matchedDevice?.name || device.code
} else { } else {
return false return false
} }
...@@ -603,7 +604,9 @@ ...@@ -603,7 +604,9 @@
} }
}.bind(this)).sort(function (a, b) { }.bind(this)).sort(function (a, b) {
return (codeToSeqMap[a.code] || Number.MAX_SAFE_INTEGER) - (codeToSeqMap[b.code] || Number.MAX_SAFE_INTEGER); return (codeToSeqMap[a.code] || Number.MAX_SAFE_INTEGER) - (codeToSeqMap[b.code] || Number.MAX_SAFE_INTEGER);
}); })
// 过滤没有信息项的数据
this.deviceList = deviceList.filter(item => item.id)
}, },
formatTime: function (seconds) { formatTime: function (seconds) {
......
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