Refine transaction filtering logic by adjusting time-based pre-filtering with wraparound midnight support and improving detail parsing for extracting transaction metadata.
This commit is contained in:
parent
8b62dc567c
commit
ffbb2769f8
@ -429,15 +429,16 @@ void GetLastTransactionsScript::doStart() {
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Amount match:" << tx.amount
|
||||
<< "date:" << tx.date << "time:" << tx.time;
|
||||
|
||||
// Проверка даты+времени (±1 час)
|
||||
if (m_searchTime.isValid() && !tx.date.isEmpty() && !tx.time.isEmpty()) {
|
||||
QDateTime txDt = QDateTime::fromString(tx.date + " " + tx.time,
|
||||
"dd.MM.yyyy HH:mm:ss");
|
||||
if (txDt.isValid()) {
|
||||
txDt.setTimeZone(tjTz);
|
||||
const qint64 diffSecs = qAbs(txDt.toUTC().secsTo(m_searchTime.toUTC()));
|
||||
if (diffSecs > 3600) {
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Time diff too big:" << diffSecs << "sec, skipping";
|
||||
// Проверка времени по HH:MM:SS (±1 час, с учётом wraparound полуночи)
|
||||
if (m_searchTime.isValid() && !tx.time.isEmpty()) {
|
||||
const QTime listTime = QTime::fromString(tx.time, "HH:mm:ss");
|
||||
const QTime searchLocalTime = m_searchTime.toTimeZone(tjTz).time();
|
||||
if (listTime.isValid() && searchLocalTime.isValid()) {
|
||||
const int diffSecs = qAbs(listTime.secsTo(searchLocalTime));
|
||||
if (diffSecs > 3600 && diffSecs < 82800) { // 82800 = 23h
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Time pre-filter skip:"
|
||||
<< tx.time << "vs" << searchLocalTime.toString("HH:mm:ss")
|
||||
<< "diff=" << diffSecs << "sec";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -453,15 +454,36 @@ void GetLastTransactionsScript::doStart() {
|
||||
AdbUtils::makeTap(m_deviceId, txNode.x(), txNode.y());
|
||||
QThread::msleep(3000);
|
||||
|
||||
// Ждём экран деталей — ищем кнопку "Назад" (признак экрана детали)
|
||||
// Ждём экран деталей Выписки — ImageView с content-desc начинающимся с "Успешный платеж"
|
||||
OcrTransactionDetail detail;
|
||||
bool detailLoaded = false;
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
if (!xmlScreenParser.findNodeByContentDesc(QString::fromUtf8("Назад")).isEmpty() ||
|
||||
!xmlScreenParser.findNodeByContentDesc(QString::fromUtf8("Поделиться")).isEmpty()) {
|
||||
for (const Node &n : xmlScreenParser.findAllNodes()) {
|
||||
if (!n.contentDesc.contains(QString::fromUtf8("Успешный платеж"))) continue;
|
||||
if (!n.contentDesc.contains(QString::fromUtf8("Дата:"))) continue;
|
||||
const QStringList lines = n.contentDesc.split('\n');
|
||||
for (int i = 0; i < lines.size(); ++i) {
|
||||
const QString key = lines[i].trimmed();
|
||||
if (i + 1 >= lines.size()) continue;
|
||||
const QString val = lines[i + 1].trimmed();
|
||||
if (key == QString::fromUtf8("Получатель:")) {
|
||||
detail.receiverAccount = val;
|
||||
} else if (key == QString::fromUtf8("Сумма:")) {
|
||||
detail.amount = val.toDouble();
|
||||
} else if (key == QString::fromUtf8("Дата:")) {
|
||||
detail.date = val;
|
||||
} else if (key == QString::fromUtf8("Время:")) {
|
||||
detail.time = val;
|
||||
}
|
||||
}
|
||||
if (n.contentDesc.contains(QString::fromUtf8("Успешный"))) {
|
||||
detail.status = QString::fromUtf8("Успешный");
|
||||
}
|
||||
detailLoaded = true;
|
||||
break;
|
||||
}
|
||||
if (detailLoaded) break;
|
||||
QThread::msleep(1500);
|
||||
}
|
||||
|
||||
@ -471,19 +493,9 @@ void GetLastTransactionsScript::doStart() {
|
||||
QThread::msleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// OCR скриншота деталей
|
||||
const QByteArray detailScreenshot = AdbUtils::captureScreenshotBytes(m_deviceId);
|
||||
const QString ocrText = recognizeTextFromImage(detailScreenshot);
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] OCR result:" << ocrText;
|
||||
|
||||
OcrTransactionDetail detail = parseDetailFromOcr(ocrText);
|
||||
|
||||
// Точечный OCR для номера операции (кроп + только цифры)
|
||||
const QString preciseOpId = recognizeOperationId(detailScreenshot);
|
||||
if (!preciseOpId.isEmpty()) {
|
||||
detail.operationId = preciseOpId;
|
||||
}
|
||||
qDebug() << "[Dushanbe::GetLastTransactions] Detail parsed:"
|
||||
<< "date=" << detail.date << "time=" << detail.time
|
||||
<< "amount=" << detail.amount << "receiver=" << detail.receiverAccount;
|
||||
|
||||
// Проверяем время ±1 час
|
||||
if (m_searchTime.isValid() && !detail.date.isEmpty() && !detail.time.isEmpty()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user