88 lines
2.2 KiB
Dart
88 lines
2.2 KiB
Dart
|
import 'package:scence_map/controllers/controller.dart';
|
||
|
|
||
|
class TaskItem {
|
||
|
int id;
|
||
|
int utc;
|
||
|
String name;
|
||
|
int workTotal;
|
||
|
List<PilePoint> list;
|
||
|
String originLabel;
|
||
|
CenterPileInfo centerPileInfo; //桩点生成中心设置
|
||
|
|
||
|
TaskItem({
|
||
|
required this.id,
|
||
|
required this.utc, //创建时间
|
||
|
required this.name, //任务名称
|
||
|
required this.workTotal,
|
||
|
required this.list,
|
||
|
required this.originLabel, //任务来源标签(本地 平台)
|
||
|
required this.centerPileInfo,
|
||
|
});
|
||
|
factory TaskItem.fromJson(Map<dynamic, dynamic> data) {
|
||
|
return TaskItem(
|
||
|
id: data['id'],
|
||
|
utc: data['utc'],
|
||
|
name: data['name'],
|
||
|
workTotal: data['workTotal'],
|
||
|
originLabel: data['originLabel'],
|
||
|
centerPileInfo: CenterPileInfo.fromJson(data['centerPileInfo']),
|
||
|
list: (data['list'] as List<dynamic>)
|
||
|
.map((item) => PilePoint.fromJson(item))
|
||
|
.toList(),
|
||
|
);
|
||
|
}
|
||
|
Map<String, dynamic> toJson() {
|
||
|
return {
|
||
|
'id': id,
|
||
|
'name': name,
|
||
|
'list': list.map((item) => item.toJson()).toList(),
|
||
|
'utc': utc,
|
||
|
'originLabel': originLabel,
|
||
|
'workTotal': workTotal,
|
||
|
'centerPileInfo': centerPileInfo.toJson(),
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class CenterPileInfo {
|
||
|
double x;
|
||
|
double y;
|
||
|
// double direction;
|
||
|
double space;
|
||
|
double pileWidth;
|
||
|
double angle;
|
||
|
List<double> distances; //桩点距离列表
|
||
|
CenterPileInfo({
|
||
|
required this.x,
|
||
|
required this.y,
|
||
|
// required this.direction,
|
||
|
this.angle = 0,
|
||
|
this.space = 5,
|
||
|
this.pileWidth = 400,
|
||
|
this.distances = const [5, 5, 5, 5], //上右下左(tips:和中心点的距离, 单位:米)
|
||
|
});
|
||
|
factory CenterPileInfo.fromJson(Map<String, dynamic> data) {
|
||
|
return CenterPileInfo(
|
||
|
x: data['x'],
|
||
|
y: data['y'],
|
||
|
// direction: data['direction'],
|
||
|
space: data['space'],
|
||
|
pileWidth: data['pileWidth'],
|
||
|
angle: data['angle'],
|
||
|
distances: List<double>.from(
|
||
|
data['distances'].map((item) => (item ?? 10).toDouble())),
|
||
|
);
|
||
|
}
|
||
|
Map<String, dynamic> toJson() {
|
||
|
return {
|
||
|
'x': x,
|
||
|
'y': y,
|
||
|
// 'direction': direction,
|
||
|
'space': space,
|
||
|
'pileWidth': pileWidth,
|
||
|
'angle': angle,
|
||
|
'distances': distances,
|
||
|
};
|
||
|
}
|
||
|
}
|