feat:订餐预约播报
This commit is contained in:
1 parent
2f72e7a3c0
commit
d1a6ac4c6c
7 files changed
+64
-38
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
@@ -117,7 +118,10 @@ class SyncCheckTool {
|
||||
if (!isNetwork) return;
|
||||
logger.i("|$_tag|$logMsg,$inSeconds秒一次,开始执行");
|
||||
try {
|
||||
await SyncTakeFoodBroadcastTool.doCheckBroadcast();
|
||||
final setting = await AppSettingTool.getSysSetting();
|
||||
await SyncTakeFoodBroadcastTool.doCheckBroadcast(
|
||||
setting.hourType ?? ProductHourType.TOTAL,
|
||||
);
|
||||
} catch (e) {
|
||||
logger.i("|$_tag|$logMsg,$inSeconds秒一次,执行失败,error:$e");
|
||||
} finally {
|
||||
|
||||
@@ -35,11 +35,14 @@ abstract class SyncTakeFoodBroadcastTool {
|
||||
);
|
||||
await broadcastDao.save(saveObj);
|
||||
logger.i("|$_tag|添加到广播记录到本地数据库,json:|${saveObj.toJson()}|");
|
||||
await SyncTakeFoodBroadcastTool.doCheckBroadcast();
|
||||
final setting = await AppSettingTool.getSysSetting();
|
||||
await SyncTakeFoodBroadcastTool.doCheckBroadcast(
|
||||
setting.hourType ?? ProductHourType.TOTAL,
|
||||
);
|
||||
}
|
||||
|
||||
// 检查广播
|
||||
static Future<void> doCheckBroadcast() async {
|
||||
static Future<void> doCheckBroadcast(ProductHourType hourType) async {
|
||||
if (_isBroadcast) {
|
||||
logger.i("|$_tag|检查打印,正在广播中");
|
||||
return;
|
||||
@@ -48,7 +51,7 @@ abstract class SyncTakeFoodBroadcastTool {
|
||||
final appC = Get.find<AppControl>();
|
||||
final broadcastDao = appC.dataBase.getBroadcastDao;
|
||||
try {
|
||||
final list = await broadcastDao.getAll();
|
||||
final list = await broadcastDao.getAll(hourType.code);
|
||||
if (ObjectUtil.isEmptyList(list)) {
|
||||
_isBroadcast = false;
|
||||
logger.i("|$_tag|检查广播,没有需要广播的订单信息");
|
||||
@@ -65,10 +68,16 @@ abstract class SyncTakeFoodBroadcastTool {
|
||||
: list.length;
|
||||
// 获取当前组的元素
|
||||
final currentGroup = list.sublist(start, end);
|
||||
String msg = "请手机尾号,";
|
||||
// 使用 Set 去重
|
||||
final Set<String> uniqueContents = {};
|
||||
for (final v in currentGroup) {
|
||||
msg += "${v.content},";
|
||||
uniqueContents.add(v.content);
|
||||
}
|
||||
String msg = "请手机尾号";
|
||||
for (final content in uniqueContents) {
|
||||
msg += "$content,";
|
||||
}
|
||||
// 逗号会影响语音播报断句
|
||||
msg = msg.substring(0, msg.length - 1);
|
||||
msg += "的用户,尽快取餐";
|
||||
// 播报当前组
|
||||
@@ -121,13 +130,13 @@ abstract class SyncTakeFoodBroadcastTool {
|
||||
if (ObjectUtil.isEmptyList(serviceList.records)) return false;
|
||||
final appC = Get.find<AppControl>();
|
||||
final broadcastDao = appC.dataBase.getBroadcastDao;
|
||||
final serviceCodes =
|
||||
serviceList.records?.map((e) => e.id.toString()).toList();
|
||||
if (ObjectUtil.isEmptyList(serviceCodes)) {
|
||||
return result;
|
||||
}
|
||||
// final serviceCodes =
|
||||
// serviceList.records?.map((e) => e.id.toString()).toList();
|
||||
// if (ObjectUtil.isEmptyList(serviceCodes)) {
|
||||
// return result;
|
||||
// }
|
||||
// 根据服务码查询本地数据库
|
||||
await broadcastDao.delByServiceCodes(serviceCodes!);
|
||||
await broadcastDao.delAll();
|
||||
final saveList = serviceList.records!
|
||||
.map((e) => _convertServiceBroadcastTodayToBroadcastEntity(e))
|
||||
.toList();
|
||||
@@ -154,7 +163,7 @@ abstract class SyncTakeFoodBroadcastTool {
|
||||
hourType:
|
||||
ProductHourType.values.fromCode(obj.hourType) ?? ProductHourType.NOON,
|
||||
enable: true,
|
||||
createTime: DateTime.now(),
|
||||
createTime: DateUtil.getDateTime(obj.createTime) ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user