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:
@@ -1,4 +1,6 @@
|
||||
const BASE_URL = 'http://localhost:18080/api/hss';
|
||||
// BASE_URL configured via manifest.json or build-time env
|
||||
// For production, update this to your actual server URL
|
||||
const BASE_URL = 'http://172.31.12.249:18080/api/hss';
|
||||
|
||||
function getHeaders() {
|
||||
const token = uni.getStorageSync('token');
|
||||
@@ -23,4 +25,80 @@ function apiPost(path, data = {}) {
|
||||
return uni.request({ url: BASE_URL + path, method: 'POST', data, header: headers });
|
||||
}
|
||||
|
||||
module.exports = { BASE_URL, apiGet, apiPost, generateIdempotencyKey };
|
||||
// ==================== GPS ====================
|
||||
|
||||
function getLocation() {
|
||||
return new Promise((resolve, reject) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.getLocation({ type: 'gcj02', success: resolve, fail: reject });
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
uni.getLocation({ type: 'gcj02', geocode: true, success: resolve, fail: reject });
|
||||
// #endif
|
||||
});
|
||||
}
|
||||
|
||||
let trajectoryTimer = null;
|
||||
function startTrajectory(workOrderId) {
|
||||
stopTrajectory();
|
||||
trajectoryTimer = setInterval(async () => {
|
||||
try {
|
||||
const loc = await getLocation();
|
||||
await apiPost('/gps/trajectory', {
|
||||
workOrderId, latitude: loc.latitude, longitude: loc.longitude, timestamp: new Date().toISOString()
|
||||
});
|
||||
} catch (e) {}
|
||||
}, 30000);
|
||||
}
|
||||
function stopTrajectory() {
|
||||
if (trajectoryTimer) { clearInterval(trajectoryTimer); trajectoryTimer = null; }
|
||||
}
|
||||
|
||||
// ==================== 拍照 ====================
|
||||
|
||||
function chooseImage(count = 1) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.chooseImage({
|
||||
count, sizeType: ['compressed'],
|
||||
// #ifdef MP-WEIXIN
|
||||
sourceType: ['camera'],
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
sourceType: ['camera', 'album'],
|
||||
// #endif
|
||||
success: resolve, fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 文件上传 ====================
|
||||
|
||||
async function uploadEvidence(filePath, entityType, entityId) {
|
||||
const fileName = filePath.split('/').pop() || 'photo.jpg';
|
||||
const ft = fileName.endsWith('.mp4') ? 'VIDEO' : fileName.endsWith('.mp3') ? 'AUDIO' : 'PHOTO';
|
||||
|
||||
const presignRes = await apiPost('/evidence/presign-upload', { fileName, fileType: ft, entityType, entityId });
|
||||
if (presignRes.data.code !== 200) throw new Error('PreSign failed');
|
||||
const { fileKey } = presignRes.data.data;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: BASE_URL + '/evidence/commit',
|
||||
filePath, name: 'file',
|
||||
formData: { fileKey, fileName, fileHash: '', fileSize: '0', contentType: 'image/jpeg' },
|
||||
header: getHeaders(),
|
||||
success: (r) => {
|
||||
try { resolve({ fileKey, response: JSON.parse(r.data) }); }
|
||||
catch (e) { resolve({ fileKey, response: r.data }); }
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addWatermark,
|
||||
BASE_URL, apiGet, apiPost, generateIdempotencyKey,
|
||||
getLocation, startTrajectory, stopTrajectory,
|
||||
chooseImage, uploadEvidence,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user