31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
const BaseService = require('./base');
|
|
|
|
class PrinterComponentService extends BaseService {
|
|
// ...existing methods...
|
|
|
|
async statusChange(data) {
|
|
const { name, status } = data;
|
|
const { app } = this;
|
|
const {ctx} = this;
|
|
const { print_computer_info } = ctx;
|
|
const { uniqueId,code, printer, warehouse, computerId } = print_computer_info;
|
|
try {
|
|
const printerKey = `printer:${computerId}:name:${name}:status`;
|
|
await app.redis.set(printerKey, status);
|
|
console.log(`打印机状态更新成功: ${computerId} -> ${status}`);
|
|
return {
|
|
status: 'success',
|
|
message: '打印机状态更新成功',
|
|
};
|
|
} catch (error) {
|
|
console.error(`打印机状态更新失败: ${error.message}`);
|
|
return {
|
|
status: 'fail',
|
|
message: '打印机状态更新失败',
|
|
error: error.message,
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = PrinterComponentService; |