优化:信息匹配上规则后再落 Msg 表

pull/286/head
pppscn 2 years ago
parent 481f634230
commit 631e9950bd

@ -57,7 +57,7 @@ class HttpService : Service(), Server.ServerListener {
.setMinTime(10000)//设置位置更新最小时间间隔(单位:毫秒); 默认间隔10000毫秒最小间隔1000毫秒
.setMinDistance(0)//设置位置更新最小距离单位默认距离0米
.setOnceLocation(false)//设置是否只定位一次,默认为 false当设置为 true 时,则只定位一次后,会自动停止定位
.setLastKnownLocation(true)//设置是否获取最后一次缓存的已知位置,默认为 true
.setLastKnownLocation(false)//设置是否获取最后一次缓存的已知位置,默认为 true
//设置定位配置参数
locationClient.setLocationOption(locationOption)
locationClient.startLocation()

@ -80,13 +80,18 @@ class SendWorker(
return@withContext Result.failure(workDataOf("send" to "failed"))
}
val msg = Msg(0, msgInfo.type, msgInfo.from, msgInfo.content, msgInfo.simSlot, msgInfo.simInfo, msgInfo.subId)
val msgId = Core.msg.insert(msg)
val ruleListMatched: MutableList<Rule> = mutableListOf()
for (rule in ruleList) {
Log.d("SendWorker", rule.toString())
if (!rule.checkMsg(msgInfo)) continue
if (rule.checkMsg(msgInfo)) ruleListMatched.add(rule)
}
if (ruleListMatched.isEmpty()) {
return@withContext Result.failure(workDataOf("send" to "failed"))
}
val msg = Msg(0, msgInfo.type, msgInfo.from, msgInfo.content, msgInfo.simSlot, msgInfo.simInfo, msgInfo.subId)
val msgId = Core.msg.insert(msg)
for (rule in ruleListMatched) {
val sender = rule.senderList[0]
val log = Logs(0, msgInfo.type, msgId, rule.id, sender.id)
val logId = Core.logs.insert(log)

Loading…
Cancel
Save