This commit is contained in:
张成
2026-02-28 10:38:28 +08:00
parent 1a011bcc01
commit dfd3119163
44 changed files with 449 additions and 13555 deletions

View File

@@ -277,7 +277,7 @@ module.exports = {
const records = await chat_records.findAll({
where: { jobId, sn_code },
order: [['sendTime', 'ASC'], ['receiveTime', 'ASC'], ['id', 'ASC']]
order: [['updateTime', 'ASC'], ['id', 'ASC']]
});
return ctx.success(records);
@@ -338,8 +338,7 @@ module.exports = {
content,
chatType,
direction: 'sent',
sendStatus: 'pending',
sendTime: new Date()
// 对话会话表当前不再区分单条消息时间,这里仅保留必要字段
});
console.log(`[聊天管理] 消息待发送到设备 ${sn_code}:`, content);
@@ -482,8 +481,8 @@ module.exports = {
record.direction || '',
record.chatType || '',
`"${(record.content || '').replace(/"/g, '""')}"`,
record.sendTime || '',
record.receiveTime || '',
'',
'',
record.hasReply ? '是' : '否'
];
csvContent += row.join(',') + '\n';

View File

@@ -165,7 +165,7 @@ switch (type) {
break;
case 'chat':
Model = models.chat_records;
dateField = 'sendTime';
dateField = 'updateTime';
break;
default:
return ctx.fail('无效的统计类型');

View File

@@ -69,12 +69,7 @@ module.exports = {
}),
chat_records.count({
where: {
sn_code: deviceSn,
direction: 'sent',
sendTime: {
[op.gte]: todayStart,
[op.lte]: todayEnd
}
sn_code: deviceSn
}
}).catch(err => {
console.error('[统计] 查询聊天数量失败:', err);
@@ -189,14 +184,9 @@ module.exports = {
}),
chat_records.findAll({
where: {
sn_code: deviceSn,
direction: 'sent',
sendTime: {
[op.gte]: start,
[op.lte]: end
}
sn_code: deviceSn
},
attributes: ['sendTime'],
attributes: ['updateTime'],
raw: true
}).catch(err => {
console.error('[统计] 查询聊天记录失败:', err);
@@ -226,7 +216,7 @@ module.exports = {
}).length;
const chatCount = allChats.filter(item => {
const itemDate = dayjs(item.sendTime);
const itemDate = dayjs(item.updateTime);
return !itemDate.isBefore(dayStart, 'day') && !itemDate.isAfter(dayEnd, 'day');
}).length;
@@ -499,14 +489,9 @@ module.exports = {
const allChats = await chat_records.findAll({
where: {
sn_code: deviceSn,
direction: 'sent',
sendTime: {
[op.gte]: start,
[op.lte]: end
}
sn_code: deviceSn
},
attributes: ['sendTime'],
attributes: ['updateTime'],
raw: true
}).catch(err => {
console.error('[统计] 查询聊天记录失败:', err);
@@ -523,7 +508,7 @@ module.exports = {
const dayEnd = currentDate.endOf('day');
const count = allChats.filter(item => {
const itemDate = dayjs(item.sendTime);
const itemDate = dayjs(item.updateTime);
return !itemDate.isBefore(dayStart, 'day') && !itemDate.isAfter(dayEnd, 'day');
}).length;

View File

@@ -439,9 +439,7 @@ return ctx.success({
return ctx.fail('任务不存在');
}
if (task.status !== 'failed') {
return ctx.fail('只能重试失败的任务');
}
await task_status.update({
status: 'pending',