case 语法示例
SELECT case
when var_id=33 then '主轴过载报警'
when var_id=34 then '数字伺服报警'
when var_id=35 then '编码器故障报警'
when var_id=36 then '冷却液未开报警'
when var_id=37 then '停止偏差报警'
else '未知报警'
end as alarms, count(var_id) as times FROM "ol_1001_33" where "value"=TRUE and "time" <= CURRENT_DATE - 5 group by var_id
简单的SQL语句
select * from ol_1001_17 order by time desc limit 20
设备类型选择后控制表格tb_EVes4里面的数据
export function chooseDevType(context,value) {
context.getComponent("tb_EVes4").dispatch("reload", {
values: {type_id:context.getComponent("tree_aXlCC").getSelectData().values.id}
});
}
开灯
export async function tb_o_click_3m7B(context, row, index) {
await context
.request("device", "sendMqttMessage", {
values: { ...row, status: 1 },
})
.then(async (res) => {
context.Message({ type: "success", message: "OK" });
})
.catch(async (err) => {
context.Message({ type: "warnning", message: "FAIL" });
});
}
订单模态框(设备选择)
export function handleClick(context, value) {
const nodes = getNodes(value)
let locationId = value.values.id
let ids = nodes.map(item => Number(item.uniqueKey))
ids.push(locationId)
const table = context.getComponent('s_table_6w7w');//注意修改为实际的值
table.dispatch('reload', { values:{"type_id":ids}})
}
export function getNodes(node,result=[]){
node.children.forEach(item=>{
result.push(item)
getNodes(item,result)
})
return result
}
//给设备名称添加
export function handleFocusEquipmentInput(context) {
const modal = context.getModal('modal_pAHw')
modal.open({
title: '选择设备',
onOpen: function (cxts) {
},
onClose: function (cxts, arg) {
if (arg && arg.length) {
const form = context.getComponent('layoutform_QB1fi')
form.addValues({
device_code: arg[0].device_code,
device_name: `[${arg[0].device_code}]${arg[0].name}`
})
}
}
})
}