- 新增滑动续签功能:人工触屏触发本地心跳 + 30秒节流刷新JWT,避免作业中令牌过期 - 拆分质量检验权限:过程检/完工检使用不同权限码,细化权限粒度 - 新增操作人用户ID字段:报工、拧紧记录落库时携带可信用户ID,解决身份追溯问题 - 移除编译期默认密钥,启动期校验所有必要密钥非空,防止密钥泄露风险 - 修复WMS附件越权遍历问题:使用UUID文件名替代顺序ID访问附件 - 实现登录态过期数据隔离:仅返回当前操作人的待同步数据,避免身份混淆
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"bj_power_workstation/internal/svc"
|
|
)
|
|
|
|
// syncFlushHandler POST /api/sync/flush 手动立即执行一轮同步,返回本次成功条数。
|
|
func syncFlushHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
count := ctx.Syncer.RunOnce(r.Context())
|
|
ok(w, map[string]any{
|
|
"count": count,
|
|
"message": "本轮同步完成",
|
|
})
|
|
}
|
|
}
|
|
|
|
// syncStatsHandler GET /api/sync/stats 返回「当前登录人」尚未成功上报的本地数据(失败列表),
|
|
// 供前端在「同一人重新登录」时仅展示失败信息(不自动打开页面)。他人数据不被返回、不可见。
|
|
func syncStatsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ss, err := ctx.Store.GetStationSession()
|
|
if err != nil || ss == nil {
|
|
ok(w, map[string]any{"pendingTorque": 0, "pendingQueue": 0, "pendingTotal": 0, "queue": []any{}, "torque": []any{}})
|
|
return
|
|
}
|
|
queue, _ := ctx.Store.PendingQueueItemsForOperator(ss.UserID, 200)
|
|
torque, _ := ctx.Store.PendingTorqueResultsForOperator(ss.UserID, 200)
|
|
ok(w, map[string]any{
|
|
"pendingQueue": len(queue),
|
|
"pendingTorque": len(torque),
|
|
"pendingTotal": len(queue) + len(torque),
|
|
"queue": queue,
|
|
"torque": torque,
|
|
})
|
|
}
|
|
} |