Commit 76b869d4 by guibin

获取车间工作时间接口修改

parent 79ada6d9
......@@ -13,6 +13,7 @@ env = Environment(loader=templateloader)
class ThtProject(http.Controller):
@http.route('/tht/get/equipment/working_time', type='json', auth="none", csrf=False, cors='*')
def get_equipment_working_time(self, **kwargs):
"""获取车间工作时间"""
jsonrequest = http.request.jsonrequest
plant_name = jsonrequest.get("plant_name", False)
domain = [("code", "!=", False)]
......@@ -20,28 +21,22 @@ class ThtProject(http.Controller):
domain.append(("plant_id.name", "=", plant_name))
equipment_ids = http.request.env['roke.mes.equipment'].sudo().search(domain)
today = datetime.now()
start_working_time_list = []
end_working_time_list = []
wait_time_list = []
start_working_time = {}
end_working_time = {}
wait_time = {}
plant_ids = equipment_ids.mapped("plant_id")
for plant_id in plant_ids:
config_id = http.request.env['plant.working.time.config'].sudo().search([("plant_id", "=", plant_id.id)], limit=1)
for item in equipment_ids.filtered(lambda x: x.plant_id == plant_id):
start_hour = math.floor(config_id.start_time)
start_working_time_list.append({
item.code: datetime.combine(today, time(start_hour, int((config_id.start_time - start_hour) * 60))).strftime("%Y-%m-%d %H:%M:%S")
})
start_working_time[item.code] = datetime.combine(today, time(start_hour, int((config_id.start_time - start_hour) * 60))).strftime("%Y-%m-%d %H:%M:%S")
end_hour = math.floor(config_id.end_time)
end_working_time_list.append({
item.code: datetime.combine(today, time(end_hour, int((config_id.end_time - end_hour) * 60))).strftime("%Y-%m-%d %H:%M:%S")
})
wait_time_list.append({
item.code: config_id.wait_time
})
end_working_time[item.code] = datetime.combine(today, time(end_hour, int((config_id.end_time - end_hour) * 60))).strftime("%Y-%m-%d %H:%M:%S")
wait_time[item.code] = config_id.wait_time
return {"state": "success", "msgs": "获取数据成功!",
"start_working_time_list": start_working_time_list,
"end_working_time_list": end_working_time_list,
"wait_time_list": wait_time_list}
"start_working_time": start_working_time,
"end_working_time": end_working_time,
"wait_time": wait_time}
class RokeMesThreeColourLightExt(RokeMesThreeColourLight):
......
......@@ -408,14 +408,14 @@
// 处理JSON-RPC格式的响应
if (response.data && response.data.result && response.data.result.state === "success") {
// 获取计划运行时间数据
const start_working_time_list = response.data.result.start_working_time_list || [];
const end_working_time_list = response.data.result.end_working_time_list || [];
const wait_time_list = response.data.result.wait_time_list || [];
const start_working_time = response.data.result.start_working_time || [];
const end_working_time = response.data.result.end_working_time || [];
const wait_time = response.data.result.wait_time || [];
// 调用设备状态接口
await this.getDeviceStateList(start_working_time_list, end_working_time_list, wait_time_list);
await this.getDeviceStateList(start_working_time, end_working_time, wait_time);
return start_working_time_list, end_working_time_list, wait_time_list;
return start_working_time, end_working_time, wait_time;
} else {
const errorMsg = response.data.result
? response.data.result.message
......@@ -460,7 +460,7 @@
},
// 获取设备状态列表
async getDeviceStateList(start_working_time_list, end_working_time_list, wait_time_list) {
async getDeviceStateList(start_time, end_time, wait_time) {
try {
// 使用CORS代理
// 发送请求获取设备状态
......@@ -469,9 +469,9 @@
url: this.baseURL + "/public/device_efficiency/device_working_time_state_list",
data: {
factory_code: this.factoryCode,
start_time: start_working_time_list,
end_time: end_working_time_list,
wait_time: wait_time_list,
start_time: start_time,
end_time: end_time,
wait_time: wait_time,
},
headers: {
"Content-Type": "application/json",
......
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