fix:关闭广布bug

This commit is contained in:
dzc committed 2025-05-13 18:13:43 +08:00
1 parent 273759a549
commit d309b9fcbc
7 files changed
+60 -20

No files matched your search

+31
View File
@@ -47,4 +47,35 @@ class TtsManage {
static Future<void> dispose() async {
await _flutterTts.stop();
}
/// 将数字转换为中文读法(手机号码格式)
/// 特别处理:1读为"幺",其他数字正常读法
static String numberToChineseReading(String number) {
if (number.isEmpty) return "";
// 数字到中文读法的映射
const Map<String, String> digitToChinese = {
'0': '零',
'1': '幺', // 手机号中1读为"幺"
'2': '二',
'3': '三',
'4': '四',
'5': '五',
'6': '六',
'7': '七',
'8': '八',
'9': '九',
};
// 逐位转换
StringBuffer result = StringBuffer();
for (int i = 0; i < number.length; i++) {
String digit = number[i];
if (digitToChinese.containsKey(digit)) {
result.write(digitToChinese[digit]);
} else {
// 如果不是数字,保持原样
result.write(digit);
}
}
return result.toString();
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ class SyncCheckTool {
Duration printInterval = const Duration(seconds: 60 * 10);
Duration broadcastInterval = const Duration(seconds: 60 * 3);
Duration broadcastInterval = const Duration(seconds: 60 * 2);
Timer? mqTimer;
@@ -76,7 +76,7 @@ abstract class SyncTakeFoodBroadcastTool {
}
String msg = "请手机尾号";
for (final content in uniqueContents) {
msg += "$content,";
msg += "${TtsManage.numberToChineseReading(content)},";
}
// 逗号会影响语音播报断句
msg = msg.substring(0, msg.length - 1);
@@ -143,16 +143,23 @@ abstract class SyncTakeFoodBroadcastTool {
}
return false;
}
// final serviceCodes =
// serviceList.records?.map((e) => e.id.toString()).toList();
// if (ObjectUtil.isEmptyList(serviceCodes)) {
// return result;
// }
// 根据服务码查询本地数据库
await broadcastDao.delAll();
// 转化为 BroadcastEntity
final saveList = serviceList.records!
.map((e) => _convertServiceBroadcastTodayToBroadcastEntity(e))
.toList();
// 查询全部本地数据
final localList = await broadcastDao.findAllPage("-1", 999, 0);
final localServiceCode = localList.map((i) => i.serviceCode).toList();
for (final i in saveList) {
if (localServiceCode.contains(i.serviceCode)) {
final target =
localList.firstWhereOrNull((j) => j.serviceCode == i.serviceCode);
if (target != null) {
i.enable = target.enable;
}
}
}
await broadcastDao.delAll();
await broadcastDao.batchSave(saveList);
return result;
}