Umstellung auf UTC Timestamp
This commit is contained in:
1 parent
fcb3ecdbb4
commit
d5ec222efd
41 files changed
+145
-665
No files matched your search
@@ -195,7 +195,7 @@ class _ApproachAreaPageState extends State<ApproachAreaPage> with ProducerMixin,
|
||||
|
||||
if (position != null) {
|
||||
setPosMessage.track = ZipTrack();
|
||||
setPosMessage.track!.time = DateTime.now().toIso8601String();
|
||||
setPosMessage.track!.time = Util.toUnixMillisUtc(DateTime.now());
|
||||
setPosMessage.track!.pos = ZipTrackPos();
|
||||
setPosMessage.track!.pos!.lat = position.latitude;
|
||||
setPosMessage.track!.pos!.long = position.longitude;
|
||||
|
||||
@@ -231,7 +231,7 @@ class _AssignedJobsPageState extends State<AssignedJobsPage> with ProducerMixin,
|
||||
message.ver = job.ver.toString();
|
||||
message.item = item;
|
||||
message.track = Track();
|
||||
message.track.time = DateTime.now().toUtc().toIso8601String();
|
||||
message.track.time = Util.toUnixMillisUtc(DateTime.now().toUtc());
|
||||
message.track.pos = FinTaskPos();
|
||||
message.track.pos!.lat = currentPosition != null ? currentPosition.latitude : 0.0;
|
||||
message.track.pos!.long = currentPosition != null ? currentPosition.longitude : 0.0;
|
||||
|
||||
@@ -420,7 +420,7 @@ class _MainPageState extends State<MainPage> with ConsumerMixin, ProducerMixin {
|
||||
var logoutMessage = LogoutMessage();
|
||||
if (position != null) {
|
||||
logoutMessage.pos = LogoutMessagePosition();
|
||||
logoutMessage.pos!.time = position.timestamp.toIso8601String();
|
||||
logoutMessage.pos!.time = Util.toUnixMillisUtc(position.timestamp);
|
||||
logoutMessage.pos!.lat = position.latitude;
|
||||
logoutMessage.pos!.long = position.longitude;
|
||||
logoutMessage.pos!.acc = position.accuracy.toInt();
|
||||
|
||||
@@ -93,7 +93,7 @@ class _MessagesPageState extends State<MessagesPage> with ProducerMixin {
|
||||
message.text = text.text;
|
||||
message.from = _sid;
|
||||
message.subj = '';
|
||||
message.time = now.toUtc().toIso8601String();
|
||||
message.time = Util.toUnixMillisUtc(now.toUtc());
|
||||
message.read = true;
|
||||
message.id = await sbmessage.ChatMessage.getNextId();
|
||||
|
||||
@@ -128,8 +128,7 @@ class _MessagesPageState extends State<MessagesPage> with ProducerMixin {
|
||||
for (var message in messages) {
|
||||
_messages.add(types.TextMessage(
|
||||
author: message.from == _sid ? _user : _central,
|
||||
createdAt:
|
||||
DateTime.parse(message.time).toLocal().millisecondsSinceEpoch,
|
||||
createdAt: message.time * 1000,
|
||||
id: message.id.toString(),
|
||||
text: "${message.subj}\n${message.text}",
|
||||
));
|
||||
@@ -215,7 +214,7 @@ class _MessagesPageState extends State<MessagesPage> with ProducerMixin {
|
||||
|
||||
var chatMessagesShowed = ChatMessagesReceived();
|
||||
chatMessagesShowed.ids = chatMessageIds;
|
||||
chatMessagesShowed.time = DateTime.now().toUtc().toIso8601String();
|
||||
chatMessagesShowed.time = Util.toUnixMillisUtc(DateTime.now().toUtc());
|
||||
|
||||
sendMessage(
|
||||
routingKey: Constants.messageTopicPublishPayload,
|
||||
|
||||
@@ -400,10 +400,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
void _processPickupDeliveryStatusTask(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
if (!mounted) return;
|
||||
showPickupDeliveryStatusPopup(currentContext, taskInfo, (tourEntry, remark) async {
|
||||
if (!context.mounted) return;
|
||||
showPickupDeliveryStatusPopup(MyApp.appNavigatorKey.currentContext!, taskInfo, (tourEntry, remark) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.code = tourEntry!.code;
|
||||
answer.val = remark;
|
||||
@@ -428,10 +427,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
|
||||
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
if (!mounted) return;
|
||||
showSignaturePopup(currentContext, taskInfo, (String? signature) async {
|
||||
if (!context.mounted) return;
|
||||
showSignaturePopup(MyApp.appNavigatorKey.currentContext!, taskInfo, (String? signature) async {
|
||||
MyApp.suppressAcceptDialog = false;
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
@@ -491,12 +489,12 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
message.trId = widget.tour.id;
|
||||
message.task = Task();
|
||||
message.task.sId = taskInfo.task.sId;
|
||||
message.task.time = DateTime.now().toIso8601String();
|
||||
message.task.time = Util.toUnixMillisUtc(DateTime.now().toUtc());
|
||||
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
if (position != null) {
|
||||
message.task.pos = FinTaskPos();
|
||||
message.task.pos!.time = DateTime.now().toIso8601String();
|
||||
message.task.pos!.time = Util.toUnixMillisUtc(position.timestamp);
|
||||
message.task.pos!.lat = position.latitude;
|
||||
message.task.pos!.long = position.longitude;
|
||||
} else {
|
||||
@@ -514,9 +512,10 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
|
||||
var finTourTask = FinTourTask();
|
||||
finTourTask.sId = taskInfo.task.sId;
|
||||
finTourTask.time = DateTime.now().toIso8601String();
|
||||
finTourTask.time = Util.toUnixMillisUtc(DateTime.now().toUtc());
|
||||
if (position != null) {
|
||||
finTourTask.pos = FinTaskPos();
|
||||
finTourTask.pos!.time = Util.toUnixMillisUtc(position.timestamp);
|
||||
finTourTask.pos!.lat = position.latitude;
|
||||
finTourTask.pos!.long = position.longitude;
|
||||
finTourTask.pos!.acc = position.accuracy.toInt();
|
||||
@@ -535,7 +534,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
if (position != null) {
|
||||
finTourMessage.track = Track();
|
||||
finTourMessage.track!.time = DateTime.now().toIso8601String();
|
||||
finTourMessage.track!.time = Util.toUnixMillisUtc(DateTime.now().toUtc());
|
||||
finTourMessage.track!.pos = FinTaskPos();
|
||||
finTourMessage.track!.pos!.lat = position.latitude;
|
||||
finTourMessage.track!.pos!.long = position.longitude;
|
||||
|
||||
+6
-12
@@ -426,7 +426,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
}
|
||||
|
||||
void _replaceContentView(ContentViewWidget widget) async {
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
contentStack.clear();
|
||||
|
||||
@@ -436,9 +435,8 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(currentContext);
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(MyApp.appNavigatorKey.currentContext!);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
@@ -447,7 +445,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
}
|
||||
|
||||
void _popContentView(int count) {
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
contentStack.pop();
|
||||
@@ -457,9 +454,8 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
|
||||
_currentContent = previousContentView;
|
||||
|
||||
if (mounted) {
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(currentContext);
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(MyApp.appNavigatorKey.currentContext!);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
@@ -468,15 +464,13 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
}
|
||||
|
||||
void _pushContentView(ContentViewWidget widget) {
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
contentStack.push(_currentContent);
|
||||
|
||||
_currentContent = widget;
|
||||
|
||||
if (mounted) {
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(currentContext);
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(MyApp.appNavigatorKey.currentContext!);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
|
||||
@@ -10,7 +10,7 @@ part 'chat_message.g.dart';
|
||||
class ChatMessage {
|
||||
late Id id;
|
||||
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
late String from;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const ChatMessageSchema = CollectionSchema(
|
||||
r'time': PropertySchema(
|
||||
id: 4,
|
||||
name: r'time',
|
||||
type: IsarType.string,
|
||||
type: IsarType.long,
|
||||
)
|
||||
},
|
||||
estimateSize: _chatMessageEstimateSize,
|
||||
@@ -66,7 +66,6 @@ int _chatMessageEstimateSize(
|
||||
bytesCount += 3 + object.from.length * 3;
|
||||
bytesCount += 3 + object.subj.length * 3;
|
||||
bytesCount += 3 + object.text.length * 3;
|
||||
bytesCount += 3 + object.time.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
@@ -80,7 +79,7 @@ void _chatMessageSerialize(
|
||||
writer.writeBool(offsets[1], object.read);
|
||||
writer.writeString(offsets[2], object.subj);
|
||||
writer.writeString(offsets[3], object.text);
|
||||
writer.writeString(offsets[4], object.time);
|
||||
writer.writeLong(offsets[4], object.time);
|
||||
}
|
||||
|
||||
ChatMessage _chatMessageDeserialize(
|
||||
@@ -95,7 +94,7 @@ ChatMessage _chatMessageDeserialize(
|
||||
object.read = reader.readBoolOrNull(offsets[1]);
|
||||
object.subj = reader.readString(offsets[2]);
|
||||
object.text = reader.readString(offsets[3]);
|
||||
object.time = reader.readString(offsets[4]);
|
||||
object.time = reader.readLong(offsets[4]);
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -115,7 +114,7 @@ P _chatMessageDeserializeProp<P>(
|
||||
case 3:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 4:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readLong(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
@@ -688,54 +687,46 @@ extension ChatMessageQueryFilter
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeGreaterThan(
|
||||
String value, {
|
||||
int value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeLessThan(
|
||||
String value, {
|
||||
int value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
@@ -744,76 +735,6 @@ extension ChatMessageQueryFilter
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'time',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition> timeIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'time',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QAfterFilterCondition>
|
||||
timeIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'time',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
@@ -992,10 +913,9 @@ extension ChatMessageQueryWhereDistinct
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, ChatMessage, QDistinct> distinctByTime(
|
||||
{bool caseSensitive = true}) {
|
||||
QueryBuilder<ChatMessage, ChatMessage, QDistinct> distinctByTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'time', caseSensitive: caseSensitive);
|
||||
return query.addDistinctBy(r'time');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1032,7 +952,7 @@ extension ChatMessageQueryProperty
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ChatMessage, String, QQueryOperations> timeProperty() {
|
||||
QueryBuilder<ChatMessage, int, QQueryOperations> timeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'time');
|
||||
});
|
||||
@@ -1045,7 +965,7 @@ extension ChatMessageQueryProperty
|
||||
|
||||
ChatMessage _$ChatMessageFromJson(Map<String, dynamic> json) => ChatMessage()
|
||||
..id = (json['id'] as num).toInt()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..from = json['from'] as String
|
||||
..subj = json['subj'] as String
|
||||
..text = json['text'] as String
|
||||
|
||||
@@ -19,7 +19,7 @@ class Reaction {
|
||||
|
||||
@JsonSerializable()
|
||||
@JsonSerializable()class Track {
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
FinTaskPos? pos;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Map<String, dynamic> _$ReactionToJson(Reaction instance) => <String, dynamic>{
|
||||
};
|
||||
|
||||
Track _$TrackFromJson(Map<String, dynamic> json) => Track()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..pos = json['pos'] == null
|
||||
? null
|
||||
: FinTaskPos.fromJson(json['pos'] as Map<String, dynamic>);
|
||||
|
||||
@@ -20,7 +20,7 @@ class MessageContent
|
||||
|
||||
late String subj;
|
||||
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
MessageContent();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ MessageContent _$MessageContentFromJson(Map<String, dynamic> json) =>
|
||||
MessageContent()
|
||||
..text = json['text'] as String
|
||||
..subj = json['subj'] as String
|
||||
..time = json['time'] as String;
|
||||
..time = (json['time'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$MessageContentToJson(MessageContent instance) =>
|
||||
<String, dynamic>{
|
||||
|
||||
@@ -33,7 +33,7 @@ class Task {
|
||||
@JsonKey(name: 's_id')
|
||||
late int sId;
|
||||
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
FinTaskPos? pos;
|
||||
|
||||
@@ -47,7 +47,7 @@ class Task {
|
||||
@embedded
|
||||
@JsonSerializable()
|
||||
class FinTaskPos {
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
late double lat;
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ const FinTaskPosSchema = Schema(
|
||||
id: 2,
|
||||
name: r'long',
|
||||
type: IsarType.double,
|
||||
),
|
||||
r'time': PropertySchema(
|
||||
id: 3,
|
||||
name: r'time',
|
||||
type: IsarType.long,
|
||||
)
|
||||
},
|
||||
estimateSize: _finTaskPosEstimateSize,
|
||||
@@ -53,6 +58,7 @@ void _finTaskPosSerialize(
|
||||
writer.writeLong(offsets[0], object.acc);
|
||||
writer.writeDouble(offsets[1], object.lat);
|
||||
writer.writeDouble(offsets[2], object.long);
|
||||
writer.writeLong(offsets[3], object.time);
|
||||
}
|
||||
|
||||
FinTaskPos _finTaskPosDeserialize(
|
||||
@@ -65,6 +71,7 @@ FinTaskPos _finTaskPosDeserialize(
|
||||
object.acc = reader.readLong(offsets[0]);
|
||||
object.lat = reader.readDouble(offsets[1]);
|
||||
object.long = reader.readDouble(offsets[2]);
|
||||
object.time = reader.readLong(offsets[3]);
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -81,6 +88,8 @@ P _finTaskPosDeserializeProp<P>(
|
||||
return (reader.readDouble(offset)) as P;
|
||||
case 2:
|
||||
return (reader.readDouble(offset)) as P;
|
||||
case 3:
|
||||
return (reader.readLong(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
@@ -264,6 +273,59 @@ extension FinTaskPosQueryFilter
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<FinTaskPos, FinTaskPos, QAfterFilterCondition> timeEqualTo(
|
||||
int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'time',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<FinTaskPos, FinTaskPos, QAfterFilterCondition> timeGreaterThan(
|
||||
int value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<FinTaskPos, FinTaskPos, QAfterFilterCondition> timeLessThan(
|
||||
int value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<FinTaskPos, FinTaskPos, QAfterFilterCondition> timeBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'time',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension FinTaskPosQueryObject
|
||||
@@ -293,7 +355,7 @@ Map<String, dynamic> _$FinTaskToJson(FinTask instance) => <String, dynamic>{
|
||||
|
||||
Task _$TaskFromJson(Map<String, dynamic> json) => Task()
|
||||
..sId = (json['s_id'] as num).toInt()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..pos = json['pos'] == null
|
||||
? null
|
||||
: FinTaskPos.fromJson(json['pos'] as Map<String, dynamic>);
|
||||
@@ -305,12 +367,14 @@ Map<String, dynamic> _$TaskToJson(Task instance) => <String, dynamic>{
|
||||
};
|
||||
|
||||
FinTaskPos _$FinTaskPosFromJson(Map<String, dynamic> json) => FinTaskPos()
|
||||
..time = (json['time'] as num).toInt()
|
||||
..lat = (json['lat'] as num).toDouble()
|
||||
..long = (json['long'] as num).toDouble()
|
||||
..acc = (json['acc'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$FinTaskPosToJson(FinTaskPos instance) =>
|
||||
<String, dynamic>{
|
||||
'time': instance.time,
|
||||
'lat': instance.lat,
|
||||
'long': instance.long,
|
||||
'acc': instance.acc,
|
||||
|
||||
@@ -39,7 +39,7 @@ class FinTourTask {
|
||||
@JsonKey(name: 's_id')
|
||||
late int sId;
|
||||
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
String? val;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Map<String, dynamic> _$FinTourToJson(FinTour instance) => <String, dynamic>{
|
||||
|
||||
FinTourTask _$FinTourTaskFromJson(Map<String, dynamic> json) => FinTourTask()
|
||||
..sId = (json['s_id'] as num).toInt()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..val = json['val'] as String?
|
||||
..code = (json['code'] as num?)?.toInt()
|
||||
..sign = json['sign'] as String?
|
||||
|
||||
@@ -15,7 +15,7 @@ class LogoutMessage {
|
||||
|
||||
@JsonSerializable()
|
||||
class LogoutMessagePosition {
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
late double lat;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Map<String, dynamic> _$LogoutMessageToJson(LogoutMessage instance) =>
|
||||
LogoutMessagePosition _$LogoutMessagePositionFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
LogoutMessagePosition()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..lat = (json['lat'] as num).toDouble()
|
||||
..long = (json['long'] as num).toDouble()
|
||||
..acc = (json['acc'] as num).toInt();
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'messages_showed.g.dart';
|
||||
class ChatMessagesReceived {
|
||||
late List<String> ids;
|
||||
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
ChatMessagesReceived();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ ChatMessagesReceived _$ChatMessagesReceivedFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
ChatMessagesReceived()
|
||||
..ids = (json['ids'] as List<dynamic>).map((e) => e as String).toList()
|
||||
..time = json['time'] as String;
|
||||
..time = (json['time'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$ChatMessagesReceivedToJson(
|
||||
ChatMessagesReceived instance) =>
|
||||
|
||||
@@ -46,7 +46,7 @@ class SyncJobMessageJob {
|
||||
|
||||
@JsonSerializable()
|
||||
class SyncMessagePos {
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
late double lat;
|
||||
|
||||
|
||||
@@ -48,12 +48,14 @@ Map<String, dynamic> _$SyncJobMessageJobToJson(SyncJobMessageJob instance) =>
|
||||
|
||||
SyncMessagePos _$SyncMessagePosFromJson(Map<String, dynamic> json) =>
|
||||
SyncMessagePos()
|
||||
..time = (json['time'] as num).toInt()
|
||||
..lat = (json['lat'] as num).toDouble()
|
||||
..long = (json['long'] as num).toDouble()
|
||||
..acc = (json['acc'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$SyncMessagePosToJson(SyncMessagePos instance) =>
|
||||
<String, dynamic>{
|
||||
'time': instance.time,
|
||||
'lat': instance.lat,
|
||||
'long': instance.long,
|
||||
'acc': instance.acc,
|
||||
|
||||
@@ -4,7 +4,7 @@ part 'track_message.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class TrackPosition {
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
late double lat;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ part of 'track_message.dart';
|
||||
|
||||
TrackPosition _$TrackPositionFromJson(Map<String, dynamic> json) =>
|
||||
TrackPosition()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..lat = (json['lat'] as num).toDouble()
|
||||
..long = (json['long'] as num).toDouble()
|
||||
..acc = (json['acc'] as num).toInt();
|
||||
|
||||
@@ -8,7 +8,7 @@ class TrackStationMessage {
|
||||
@JsonKey(name: 's_id')
|
||||
late int sid;
|
||||
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
FinTaskPos? pos;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ part of 'track_station_message.dart';
|
||||
TrackStationMessage _$TrackStationMessageFromJson(Map<String, dynamic> json) =>
|
||||
TrackStationMessage()
|
||||
..sid = (json['s_id'] as num).toInt()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..pos = json['pos'] == null
|
||||
? null
|
||||
: FinTaskPos.fromJson(json['pos'] as Map<String, dynamic>);
|
||||
|
||||
@@ -20,7 +20,7 @@ class ZipSetPos {
|
||||
@embedded
|
||||
@JsonSerializable()
|
||||
class ZipTrack {
|
||||
late String time;
|
||||
late int time;
|
||||
|
||||
ZipTrackPos? pos;
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ const ZipTrackSchema = Schema(
|
||||
r'time': PropertySchema(
|
||||
id: 1,
|
||||
name: r'time',
|
||||
type: IsarType.string,
|
||||
type: IsarType.long,
|
||||
)
|
||||
},
|
||||
estimateSize: _zipTrackEstimateSize,
|
||||
@@ -297,7 +297,6 @@ int _zipTrackEstimateSize(
|
||||
value, allOffsets[ZipTrackPos]!, allOffsets);
|
||||
}
|
||||
}
|
||||
bytesCount += 3 + object.time.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
@@ -313,7 +312,7 @@ void _zipTrackSerialize(
|
||||
ZipTrackPosSchema.serialize,
|
||||
object.pos,
|
||||
);
|
||||
writer.writeString(offsets[1], object.time);
|
||||
writer.writeLong(offsets[1], object.time);
|
||||
}
|
||||
|
||||
ZipTrack _zipTrackDeserialize(
|
||||
@@ -328,7 +327,7 @@ ZipTrack _zipTrackDeserialize(
|
||||
ZipTrackPosSchema.deserialize,
|
||||
allOffsets,
|
||||
);
|
||||
object.time = reader.readString(offsets[1]);
|
||||
object.time = reader.readLong(offsets[1]);
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -346,7 +345,7 @@ P _zipTrackDeserializeProp<P>(
|
||||
allOffsets,
|
||||
)) as P;
|
||||
case 1:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readLong(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
@@ -371,54 +370,46 @@ extension ZipTrackQueryFilter
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeGreaterThan(
|
||||
String value, {
|
||||
int value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeLessThan(
|
||||
String value, {
|
||||
int value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
@@ -427,75 +418,6 @@ extension ZipTrackQueryFilter
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'time',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'time',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'time',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ZipTrack, ZipTrack, QAfterFilterCondition> timeIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'time',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
@@ -790,7 +712,7 @@ Map<String, dynamic> _$ZipSetPosToJson(ZipSetPos instance) => <String, dynamic>{
|
||||
};
|
||||
|
||||
ZipTrack _$ZipTrackFromJson(Map<String, dynamic> json) => ZipTrack()
|
||||
..time = json['time'] as String
|
||||
..time = (json['time'] as num).toInt()
|
||||
..pos = json['pos'] == null
|
||||
? null
|
||||
: ZipTrackPos.fromJson(json['pos'] as Map<String, dynamic>);
|
||||
|
||||
@@ -375,7 +375,7 @@ _sendAnswer(SharedMapReference mapReference, Job job, int item) async {
|
||||
message.ver = job.ver.toString();
|
||||
message.item = item;
|
||||
message.track = Track();
|
||||
message.track.time = DateTime.now().toUtc().toIso8601String();
|
||||
message.track.time = Util.toUnixMillisUtc(DateTime.now().toUtc());
|
||||
message.track.pos = FinTaskPos();
|
||||
message.track.pos!.lat = currentPosition != null ? currentPosition.latitude : 0.0;
|
||||
message.track.pos!.long = currentPosition != null ? currentPosition.longitude : 0.0;
|
||||
|
||||
@@ -595,7 +595,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
answer.utcUnixTime = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
answer.pos = SyncMessagePos();
|
||||
answer.pos!.time = DateTime.now().toUtc().toIso8601String();
|
||||
answer.pos!.time = currentPosition != null ? Util.toUnixMillisUtc(currentPosition.timestamp.toUtc()) : 0;
|
||||
answer.pos!.lat = currentPosition != null ? currentPosition.latitude : 0.0;
|
||||
answer.pos!.long = currentPosition != null ? currentPosition.longitude : 0.0;
|
||||
answer.pos!.acc = currentPosition != null ? currentPosition.accuracy.toInt() : 0;
|
||||
@@ -622,7 +622,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
var trackMessage = TrackPosition();
|
||||
|
||||
if (position != null) {
|
||||
trackMessage.time = position.timestamp.toIso8601String();
|
||||
trackMessage.time = Util.toUnixMillisUtc(position.timestamp);
|
||||
trackMessage.lat = position.latitude;
|
||||
trackMessage.long = position.longitude;
|
||||
trackMessage.acc = position.accuracy.toInt();
|
||||
|
||||
+10
-3
@@ -18,6 +18,13 @@ import '../Tools/colored_safe_area.dart';
|
||||
class Util {
|
||||
static late SharedPreferences prefs;
|
||||
|
||||
// DateTime → UTC Unix timestamps
|
||||
static int toUnixMillisUtc(DateTime dt) => dt.toUtc().millisecondsSinceEpoch;
|
||||
static int nowUnixMillisUtc() => DateTime.now().toUtc().millisecondsSinceEpoch;
|
||||
// Optional: Unix seconds
|
||||
static int toUnixSecondsUtc(DateTime dt) => dt.toUtc().millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
|
||||
static init() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
@@ -427,7 +434,7 @@ Future<void> showMessageDialog(BuildContext context, String title, String messag
|
||||
|
||||
class DecimalTextInputFormatter extends TextInputFormatter {
|
||||
int maxLength;
|
||||
|
||||
|
||||
int decimalPlaces;
|
||||
|
||||
DecimalTextInputFormatter({required this.maxLength, required this.decimalPlaces});
|
||||
@@ -440,9 +447,9 @@ class DecimalTextInputFormatter extends TextInputFormatter {
|
||||
if (text != "") {
|
||||
RegExp regExp;
|
||||
if (decimalPlaces > 0) {
|
||||
regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,${' + decimalPlaces.toString() + '}');
|
||||
regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,${decimalPlaces}');
|
||||
} else {
|
||||
regExp = RegExp(r'[0-9]{0,' + maxLength.toString() +'}');
|
||||
regExp = RegExp(r'[0-9]{0,${maxLength}}');
|
||||
}
|
||||
filteredText = regExp.stringMatch(text);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user