修复高清地图(贴图)不支持手动滑动地理位置显示问题;修复地图显示上次设备位置的异常情况;修复打点保存少携带mode +orgid参数问题。

This commit is contained in:
2026-09-04 08:43:43 +08:00
parent 5141d6e83f
commit db81816b78
7 changed files with 112 additions and 18 deletions

View File

@@ -1,11 +1,13 @@
enum WorkMode {
bow(0), // 作业模式:bow,值为0
custom(2); // 作业模式:custom,值为2
bow(0, 'coverage'), // 作业模式:bow,值为0;后端 mode="coverage"(覆盖/区域)
custom(2, 'single_point'); // 作业模式:custom,值为2;后端 mode="single_point"(自定义/单点)
// 定义枚举的数值属性
final int value;
// 🔥 对齐 Web 端:workRecord.mode 字段(Web 注释"区域还是单点")
final String modeCode;
// 枚举构造函数(必须是const)
const WorkMode(this.value);
const WorkMode(this.value, this.modeCode);
}
enum RobotMode { point, robot }

View File

@@ -184,3 +184,23 @@ class GeoSuzhouOverlay extends StatelessWidget {
);
}
}
/// 全部场站高清叠加图层(一次性构建、复用实例,避免每次重建重复请求瓦片)。
/// 用法:在 FlutterMap 的 children 里 spread 进去 —— ...kAllStationTileLayers
/// 效果:滑到任意场站区域(zoom>=16)自动叠加对应高清图;每层各自 tileBounds,框外不请求。
final List<TileLayer> kAllStationTileLayers = kStationLayerBounds.entries
.map(
(entry) => TileLayer(
tileProvider: GeoWmsProvider(
layerName: entry.key,
bounds: entry.value,
maxLevel: 21,
),
userAgentPackageName: 'com.example.app',
minZoom: 16,
maxZoom: 21,
maxNativeZoom: 21,
tileBounds: entry.value,
),
)
.toList();

View File

@@ -936,6 +936,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
required String workRecordJson,
required String plotName,
required Object? siteId,
Object? orgId,
String? mode,
}) {
// debugPrint 单条过长会被 logcat 截断,长文本统一按行拆开输出
void printLines(String text) {
@@ -960,11 +962,24 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
debugPrint('📤 [请求头] $safeHeaders');
debugPrint(
'📤 [上下文] workName=$plotName, siteId=$siteId, '
'📤 [上下文] workName=$plotName, siteId=$siteId, orgId=$orgId, mode=$mode, '
'workMode=$_currentWorkMode, robotMode=$_currentRobotMode, '
'areaMode=$_currentAreaMode, planModel=${savePath['planModel']}',
);
// 🔥 mode / planModel 一致性自检:两者必须由同一个 _currentWorkMode 推导出来
final String expectMode = savePath['planModel'] == 0
? WorkMode.bow.modeCode
: WorkMode.custom.modeCode;
debugPrint(
'📤 [模式校验] planModel=${savePath['planModel']} → 期望 mode="$expectMode",'
'实际 mode="$mode" → ${expectMode == mode ? "✅ 一致" : "❌ 不一致,检查 _currentWorkMode"}',
);
debugPrint(
'📤 [场站校验] siteId=$siteId, orgId=$orgId → '
'${orgId != null ? "✅ orgId 已带上" : "⚠️ orgId 为 null,未写入请求体(selectedSite 为空?)"}',
);
// multipart 各 part 的元信息(不消费流)
debugPrint('📤 [multipart] part 数量: ${request.files.length}');
for (var i = 0; i < request.files.length; i++) {
@@ -1079,12 +1094,17 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
debugPrint('🔍 [保存地块] ====== _savePlotData 被调用, plotName=$plotName ======');
final loc = AppLocalizations.of(context);
// 🔥 V2 适配:使用 SiteCubit 获取站点ID(从 v2 首页场站选择获取,有默认值)
final siteId = sl<SiteCubit>().state.selectedSite?.id;
// selectedSite 就是各页面左上角下拉(SiteSelectorWidget)全局维护的那个场站
final selectedSite = sl<SiteCubit>().state.selectedSite;
final siteId = selectedSite?.id;
if (siteId == null) {
debugPrint('❌ [保存地块] siteId为空,提前返回!');
_showPageToast(message: '请先在场站列表中选择一个场站!', type: ToastType.error);
return;
}
// 🔥 对齐 Web 端 orgId: currentStation?.orgId
// ⚠️ 必须和 siteId 同源(selectedSite),不要取 AppUserCubit 里登录用户的 orgId
final orgId = selectedSite?.orgId;
for (var i = 0; i < typedPathList.length; i++) {
debugPrint(typedPathList[i].toString());
}
@@ -1126,6 +1146,19 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// 🔥 jsonData 必须是对象,不能是字符串(后端 PlanPath 类型要求)
'jsonData': savePath,
};
// 🔥 对齐 Web 端 orgId(场站所属机构),与 siteId 同源于 SiteCubit.selectedSite
// Web 是 currentStation?.orgId,为 undefined 时 JSON.stringify 会丢掉该键,这里同样只在非空时加
if (orgId != null) {
workRecord['orgId'] = orgId;
}
// 🔥 对齐 Web 端 mode 字段(Web 注释"区域还是单点")
// 覆盖模式 → "coverage",自定义模式 → "single_point"
// ⚠️ 判定表达式必须和上面 planModel 用同一个,保证两字段永远同源不打架
final String modeCode = _currentWorkMode == WorkMode.bow
? WorkMode.bow.modeCode
: WorkMode.custom.modeCode;
workRecord['mode'] = modeCode;
debugPrint('📤 [保存地块] workRecord 附加字段: orgId=$orgId, mode=$modeCode');
final String workRecordJson = jsonEncode(workRecord);
final http.MultipartRequest request = http.MultipartRequest(
'POST',
@@ -1195,6 +1228,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
workRecordJson: workRecordJson,
plotName: plotName,
siteId: siteId,
orgId: orgId,
mode: modeCode,
);
// 7. 发送请求
@@ -2142,13 +2177,11 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
maxZoom: 19,
),
/// GeoServer 场站无人机高清影像叠加层(WGS84 基准,无偏移)
/// 按当前选中场站的 siteMapName 动态加载对应图层;需 zoom >= 16 才能看到
/// 当前 WMS 兜底(原生 EPSG:4326);公司补配 GWC EPSG:3857 后切 WMTS
/// 切换位置:geoserver_suzhou_layer.dart 的 kUseWmtsTile 开关
GeoSuzhouOverlay(
siteMapName: sl<SiteCubit>().state.selectedSite?.siteMapName,
),
/// GeoServer 全部场站无人机高清影像叠加层(WGS84 基准,无偏移)
/// 一次性叠加所有场站图层:滑到哪个场站区域(zoom>=16)就自动显示哪个高清图
/// 每层各自 tileBounds,框外瓦片不请求,开销极小;苏州等手动滑过去即可叠加
/// 当前 WMS 兜底(原生 EPSG:4326);公司补配 GWC EPSG:3857 后改 geoserver_suzhou_layer.dart
...kAllStationTileLayers,
//if (isDjMapShow) DJITileLayer(stationName: _currentStation.name, mapController: _mapController),
// 绘制path折线(Line模式)