平台接口改动

This commit is contained in:
lingwentao 2023-08-02 11:58:15 +08:00
parent 93967379be
commit 8a8bccd867
2 changed files with 30 additions and 30 deletions

View File

@ -231,9 +231,9 @@ class ClientMapper {
}
arr.push(ssoAppSecret);
str += ' sso_app_secret = ? ';
const data = await db(`${str} where mp_id = ?`, [...arr, id]);
return data;
}
const data = await db(`${str} where mp_id = ?`, [...arr, id]);
return data;
}
}

View File

@ -164,34 +164,34 @@ client.on('close', async () => {
client.subscribe(['1/req/#', '1/rsp/#']);
// 查询家庭数据
setInterval(async () => {
console.log(`${moment().format('YYYY-MM-DD hh:mm:ss')}查询家庭数据`);
const reqId = stringRandom(16);
const hccId = 'e6ca693e-a803-4ef4-91d6-e16131536937';
const hccInfo = await hccMapper.getInfoByHccId(
'e6ca693e-a803-4ef4-91d6-e16131536937',
);
let seId;
if (hccInfo.length) {
seId = hccInfo[0].se_id;
}
// 调用加密接口
const info = await mqttService.encrypt(
seId,
getConfig().keyAlias,
JSON.stringify({
cmd: '7',
reqId,
payload: { dataType: '01', mpId: '6433be833832fb000180193e' },
}),
);
await mqttMapper.updateLog(1);
client.publish(`2/req/${hccId}`, JSON.stringify({ message: info }), () => {
// 记录reqid放入全局缓存
global.reqIdMap.set(reqId, null);
console.log('通知成功');
});
}, 500);
// setInterval(async () => {
// console.log(`${moment().format('YYYY-MM-DD hh:mm:ss')}查询家庭数据`);
// const reqId = stringRandom(16);
// const hccId = 'e6ca693e-a803-4ef4-91d6-e16131536937';
// const hccInfo = await hccMapper.getInfoByHccId(
// 'e6ca693e-a803-4ef4-91d6-e16131536937',
// );
// let seId;
// if (hccInfo.length) {
// seId = hccInfo[0].se_id;
// }
// // 调用加密接口
// const info = await mqttService.encrypt(
// seId,
// getConfig().keyAlias,
// JSON.stringify({
// cmd: '7',
// reqId,
// payload: { dataType: '01', mpId: '6433be833832fb000180193e' },
// }),
// );
// await mqttMapper.updateLog(1);
// client.publish(`2/req/${hccId}`, JSON.stringify({ message: info }), () => {
// // 记录reqid放入全局缓存
// global.reqIdMap.set(reqId, null);
// console.log('通知成功');
// });
// }, 500);
export default client;