feat: 全系统优化 — 并发控制 + 冗余清理 + 数据流修复 + 全面测试

核心修复:
- 状态机加 SELECT FOR UPDATE 行锁,消除并发竞态
- hss_md_staff 加 role 列,登录从数据库读取真实角色
- 申请重复校验排除自身,全流程 20 步闭环通过
- 派单 SQL 修复 + 支付状态机过渡 + 完成服务 plan_item_id 修复

并发控制新增:
- RedisLockService (SET NX PX + Lua 安全解锁)
- RateLimiterService (Redis 滑动窗口 + API 拦截器)
- TransactionIsolationConfig (SERIALIZABLE for 支付回调)
- MqttPublisher (异步队列 + JDK TCP 探测)
- ObjectStorageService (AWS SigV4 预签名, 纯 JDK)

冗余清理:
- 删除 6 个死代码文件 (~620 行)
- hutool-all → JDK MessageDigest, 去 MapStruct, 去 jsr310
- haversine 提取到 GeoUtil, count/round 提取到 JdbcUtil
- 创建 platform layout 组件

前端修复:
- 登录页移除角色选择器, 由后端 JWT 返回
- 移除 ClientOnly 包裹, 页面正常渲染
- SPA fallback Nginx 配置修复

Docker: 运行时镜像 eclipse-temurin:17-jre-jammy (缩小 ~300MB)

文档: 新增系统实现与修复报告.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 11:48:07 +08:00
parent 7d92322b99
commit 01e1034cc1
387 changed files with 6220 additions and 12952 deletions

View File

@@ -0,0 +1,51 @@
// Node.js 压力测试50 并发持续创建申请
const BASE = 'http://172.31.12.249:18080/api/hss';
const H = { 'Content-Type': 'application/json', 'X-Tenant-Id': '1', 'X-Org-Id': '1', 'X-User-Role': 'ADMIN' };
let total = 0, p200 = 0, p422 = 0, p4xx = 0, p5xx = 0;
const start = Date.now();
const CONCURRENCY = 50;
const DURATION_MS = 15000;
async function createApplication() {
const key = 'stress-' + Math.random().toString(36).slice(2, 12);
try {
const r = await fetch(BASE + '/applications', {
method: 'POST',
headers: { ...H, 'Idempotency-Key': key },
body: JSON.stringify({ patientId: '2001', serviceType: 'HOME_CARE', channel: 'WECHAT',
contactName: 'StressTest', contactPhone: '13800000000', address: '梅江区', regionCode: '441402001' })
});
total++;
if (r.status === 200) p200++;
else if (r.status === 422) p422++;
else if (r.status >= 400 && r.status < 500) p4xx++;
else p5xx++;
} catch (e) { total++; p5xx++; }
}
async function main() {
console.log(`=== 压力测试: ${CONCURRENCY}并发 持续${DURATION_MS/1000}s 创建申请 ===\n`);
const endTime = Date.now() + DURATION_MS;
const tasks = [];
while (Date.now() < endTime) {
for (let i = 0; i < CONCURRENCY; i++) {
tasks.push(createApplication());
}
if (tasks.length > 500) {
await Promise.all(tasks.splice(0, 200));
}
await new Promise(r => setTimeout(r, 50));
}
await Promise.all(tasks);
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
const rps = (total / elapsed).toFixed(1);
console.log(`\n=== 压力测试结果 ===`);
console.log(`总请求: ${total} 200: ${p200} 422(重复校验): ${p422} 其他4xx: ${p4xx} 5xx: ${p5xx}`);
console.log(`耗时: ${elapsed}s RPS: ${rps} 成功率: ${(p200/total*100).toFixed(1)}%`);
}
main().catch(console.error);