feat: 实现工位终端滑动续签机制,强化安全与身份追溯
- 新增滑动续签功能:人工触屏触发本地心跳 + 30秒节流刷新JWT,避免作业中令牌过期 - 拆分质量检验权限:过程检/完工检使用不同权限码,细化权限粒度 - 新增操作人用户ID字段:报工、拧紧记录落库时携带可信用户ID,解决身份追溯问题 - 移除编译期默认密钥,启动期校验所有必要密钥非空,防止密钥泄露风险 - 修复WMS附件越权遍历问题:使用UUID文件名替代顺序ID访问附件 - 实现登录态过期数据隔离:仅返回当前操作人的待同步数据,避免身份混淆
This commit is contained in:
@@ -72,6 +72,17 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
// 方案 B:操作人取自工位登录态可信身份,忽略浏览器请求体里的 operator(防冒名);
|
||||
// operator_id 用于离线队列按操作人隔离发送(仅当前登录人自己的数据被发送)
|
||||
op := req.Operator
|
||||
opID := int64(0)
|
||||
if ss, sErr := ctx.Store.GetStationSession(); sErr == nil && ss != nil {
|
||||
if ss.Name != "" {
|
||||
op = ss.Name
|
||||
}
|
||||
opID = ss.UserID
|
||||
}
|
||||
|
||||
// 先尽力冲刷历史积压,失败不影响本次上报
|
||||
ctx.Syncer.RunOnce(r.Context())
|
||||
|
||||
@@ -80,8 +91,7 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
"orderNo": req.OrderNo,
|
||||
"flowId": req.FlowId,
|
||||
"stationNo": req.StationNo,
|
||||
"steps": req.Steps,
|
||||
"operator": req.Operator,
|
||||
"operator": op,
|
||||
}
|
||||
if len(req.Binds) > 0 {
|
||||
body["binds"] = req.Binds
|
||||
@@ -94,12 +104,12 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
payloadBytes, _ := json.Marshal(body)
|
||||
|
||||
ctx.Store.AddEventLog(req.OrderNo, req.Operator, "process_done",
|
||||
ctx.Store.AddEventLog(req.OrderNo, op, "process_done",
|
||||
"工艺完成上报 sn="+req.Sn+" stationNo="+itoa(req.StationNo)+" flowId="+itoa(req.FlowId)+" binds="+itoa(len(req.Binds)))
|
||||
|
||||
respBody, _, err := ctx.Mes.Post("/api/internal/station/report", json.RawMessage(payloadBytes))
|
||||
if err != nil {
|
||||
if qerr := ctx.Store.InsertQueueItem("process_done", string(payloadBytes)); qerr != nil {
|
||||
if qerr := ctx.Store.InsertQueueItem("process_done", string(payloadBytes), opID, op); qerr != nil {
|
||||
fail(w, http.StatusInternalServerError, "上报失败且离线队列写入失败:"+qerr.Error())
|
||||
return
|
||||
}
|
||||
@@ -139,6 +149,17 @@ func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
// 方案 B:操作人取自工位登录态可信身份,忽略浏览器请求体里的 operator(防冒名);
|
||||
// operator_id 用于离线队列按操作人隔离发送(仅当前登录人自己的数据被发送)
|
||||
op := req.Operator
|
||||
opID := int64(0)
|
||||
if ss, sErr := ctx.Store.GetStationSession(); sErr == nil && ss != nil {
|
||||
if ss.Name != "" {
|
||||
op = ss.Name
|
||||
}
|
||||
opID = ss.UserID
|
||||
}
|
||||
|
||||
// 先尽力冲刷历史积压,失败不影响本次上报
|
||||
ctx.Syncer.RunOnce(r.Context())
|
||||
|
||||
@@ -147,16 +168,16 @@ func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
"orderNo": req.OrderNo,
|
||||
"stationNo": req.StationNo,
|
||||
"flowId": req.FlowId,
|
||||
"operator": req.Operator,
|
||||
"operator": op,
|
||||
}
|
||||
payloadBytes, _ := json.Marshal(body)
|
||||
|
||||
ctx.Store.AddEventLog(req.OrderNo, req.Operator, "temp_store",
|
||||
ctx.Store.AddEventLog(req.OrderNo, op, "temp_store",
|
||||
"暂存/退回库房 sn="+req.Sn+" stationNo="+itoa(req.StationNo))
|
||||
|
||||
respBody, _, err := ctx.Mes.Post("/api/internal/station/checkin", json.RawMessage(payloadBytes))
|
||||
if err != nil {
|
||||
if qerr := ctx.Store.InsertQueueItem("temp_store", string(payloadBytes)); qerr != nil {
|
||||
if qerr := ctx.Store.InsertQueueItem("temp_store", string(payloadBytes), opID, op); qerr != nil {
|
||||
fail(w, http.StatusInternalServerError, "上报失败且离线队列写入失败:"+qerr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user