diff --git a/isolated/.env.example b/isolated/.env.example index 724f409..6a05ee2 100644 --- a/isolated/.env.example +++ b/isolated/.env.example @@ -147,11 +147,15 @@ COS_SECRET_KEY=change-me COS_REGION=ap-chengdu COS_BUCKET=emp-example-bucket +# 车辆/设备同步的中控地址,隔离环境无真实中控时保留占位即可。 SYNC_BASE_URL=https://example.com SYNC_TK=change-me SYNC_TENANT_ID=change-me SYNC_REPORT_CRON=0 30 2 * * ? -SYNC_REPORT_SYNC_ENABLED=false +# 单车报告同步开关。隔离环境由自带 emp-ws 模拟器充当中控,需开启。 +SYNC_REPORT_SYNC_ENABLED=true +# 单车报告同步地址,指向 emp-ws 容器内网地址(compose 服务名 emp-ws,容器端口 3000)。 +SYNC_REPORT_BASE_URL=http://emp-ws:3000 SYNC_REPORT_SYNC_CONCURRENCY=3 SYNC_REPORT_SYNC_GROUP_NAMES= SYNC_REPORT_CACHE_MISS_FETCH_ENABLED=false diff --git a/isolated/README.md b/isolated/README.md index e9adeb2..9a952c6 100644 --- a/isolated/README.md +++ b/isolated/README.md @@ -254,6 +254,33 @@ cd /home/admin-x99/emp/$DEPLOY_ENV/runtime dc() { docker compose --env-file .env -f docker-compose.yml -p "$DEPLOY_ENV" "$@"; } ``` +## 单车报告同步配置 + +模拟器页面的"同步"(`POST /api/simulator/backend/report/sync`)链路为: + +```text +浏览器模拟器页面 +-> emp-ws /api/simulator/backend/report/sync +-> emp-gateway -> emp-monitor /monitor/batteryEvaluation/sync +-> 中控 /sync/report(隔离环境由自带 emp-ws 模拟器兼容接口充当) +``` + +隔离环境没有真实中控,单车报告的"中控"角色由 emp-ws 容器自身提供,因此 `.env` 必须满足: + +- `SYNC_REPORT_SYNC_ENABLED=true`:关闭时 `emp-monitor` 直接跳过同步,返回 `successCount=0`,页面提示"同步未产生成功数据,已保留"。 +- `SYNC_REPORT_BASE_URL=http://emp-ws:3000`:单车报告同步地址。为空时会回退到 `SYNC_BASE_URL`(占位 `https://example.com`),导致请求不到数据。`emp-ws` 是 compose 内网服务名,`3000` 为容器内端口。 + +上述两项已在 `.env.example` 模板中给出可用默认值。改动 `.env` 后重启业务服务: + +```bash +cd /home/admin-x99/emp/emp-test/runtime +dc() { docker compose --env-file .env -f docker-compose.yml -p emp-test "$@"; } +dc up -d emp-monitor +dc logs -f emp-monitor # 应出现 [单车报告] 请求中控接口 url=http://emp-ws:3000/sync/report +``` + +如果 `emp-monitor` 走 Nacos 配置中心下发配置,需在 Nacos 控制台对应 dataId 同步修改这两项,`.env` 改动可能不生效。 + ## 甲方服务器常用命令 ```bash diff --git a/isolated/profiles/emp-test/.env.example b/isolated/profiles/emp-test/.env.example index 5788359..d6ac2ac 100644 --- a/isolated/profiles/emp-test/.env.example +++ b/isolated/profiles/emp-test/.env.example @@ -97,11 +97,15 @@ COS_REGION=ap-chengdu COS_BUCKET=emp-example-bucket COS_PUBLIC_BASE_URL= +# 车辆/设备同步的中控地址,隔离环境无真实中控时保留占位即可。 SYNC_BASE_URL=https://example.com SYNC_TK=change-me SYNC_TENANT_ID=change-me SYNC_REPORT_CRON=0 30 2 * * ? -SYNC_REPORT_SYNC_ENABLED=false +# 单车报告同步开关。隔离环境由自带 emp-ws 模拟器充当中控,需开启。 +SYNC_REPORT_SYNC_ENABLED=true +# 单车报告同步地址,指向 emp-ws 容器内网地址(compose 服务名 emp-ws,容器端口 3000)。 +SYNC_REPORT_BASE_URL=http://emp-ws:3000 SYNC_REPORT_SYNC_CONCURRENCY=3 SYNC_REPORT_SYNC_GROUP_NAMES= SYNC_REPORT_CACHE_MISS_FETCH_ENABLED=false diff --git a/isolated/profiles/emp-uat/.env.example b/isolated/profiles/emp-uat/.env.example index 2846540..6c65c2d 100644 --- a/isolated/profiles/emp-uat/.env.example +++ b/isolated/profiles/emp-uat/.env.example @@ -97,11 +97,15 @@ COS_REGION=ap-chengdu COS_BUCKET=emp-example-bucket COS_PUBLIC_BASE_URL= +# 车辆/设备同步的中控地址,隔离环境无真实中控时保留占位即可。 SYNC_BASE_URL=https://example.com SYNC_TK=change-me SYNC_TENANT_ID=change-me SYNC_REPORT_CRON=0 30 2 * * ? -SYNC_REPORT_SYNC_ENABLED=false +# 单车报告同步开关。隔离环境由自带 emp-ws 模拟器充当中控,需开启。 +SYNC_REPORT_SYNC_ENABLED=true +# 单车报告同步地址,指向 emp-ws 容器内网地址(compose 服务名 emp-ws,容器端口 3000)。 +SYNC_REPORT_BASE_URL=http://emp-ws:3000 SYNC_REPORT_SYNC_CONCURRENCY=3 SYNC_REPORT_SYNC_GROUP_NAMES= SYNC_REPORT_CACHE_MISS_FETCH_ENABLED=false