- 新增滑动续签功能:人工触屏触发本地心跳 + 30秒节流刷新JWT,避免作业中令牌过期 - 拆分质量检验权限:过程检/完工检使用不同权限码,细化权限粒度 - 新增操作人用户ID字段:报工、拧紧记录落库时携带可信用户ID,解决身份追溯问题 - 移除编译期默认密钥,启动期校验所有必要密钥非空,防止密钥泄露风险 - 修复WMS附件越权遍历问题:使用UUID文件名替代顺序ID访问附件 - 实现登录态过期数据隔离:仅返回当前操作人的待同步数据,避免身份混淆
85 lines
2.8 KiB
Go
85 lines
2.8 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"bj_power_mes/common/httpx"
|
|
"bj_power_mes/internal/handler/production"
|
|
"bj_power_mes/internal/logic"
|
|
"bj_power_mes/internal/svc"
|
|
)
|
|
|
|
// OccupyPointHandler POST /line/occupy(点位人工记账:IN 上料占位 / OUT 下料释放)
|
|
// 供工位终端在无 PLC 联调时、或上料位(IN)/末端下料检测位(11/12) 人工操作时维护点位台账(唯一事实源)。
|
|
func OccupyPointHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req struct {
|
|
PointNo string `json:"pointNo"`
|
|
Sn string `json:"sn"`
|
|
OrderNo string `json:"orderNo"`
|
|
Operator string `json:"operator"`
|
|
Action string `json:"action"` // IN=上料 / OUT=下料
|
|
}
|
|
if err := httpx.ParseJSON(r, &req); err != nil {
|
|
httpx.BadRequest(w, "请求体解析失败")
|
|
return
|
|
}
|
|
action := strings.ToUpper(strings.TrimSpace(req.Action))
|
|
if action == "" {
|
|
action = "IN"
|
|
}
|
|
if action != "IN" && action != "OUT" {
|
|
httpx.BadRequest(w, "action 仅支持 IN(上料) / OUT(下料)")
|
|
return
|
|
}
|
|
production.LogImpersonation(svcCtx, r, req.Operator, "/api/internal/line/occupy")
|
|
op := production.StationOp(r, req.Operator)
|
|
if err := logic.New(svcCtx).OccupyPoint(r.Context(), req.PointNo, req.Sn, req.OrderNo, op, action); err != nil {
|
|
httpx.Fail(w, 2407, err.Error())
|
|
return
|
|
}
|
|
msg := "上料已记账"
|
|
if action == "OUT" {
|
|
msg = "下料已释放"
|
|
}
|
|
httpx.OkMessage(w, msg, nil)
|
|
}
|
|
}
|
|
|
|
// ListPointsHandler GET /line/points(产线点位台账:上料位/工位/缓存位/接驳台/末端 当前工件)
|
|
func ListPointsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
_ = logic.New(svcCtx).InitLinePoints(r.Context())
|
|
data, err := logic.New(svcCtx).ListPoints(r.Context())
|
|
if err != nil {
|
|
httpx.Fail(w, 2401, err.Error())
|
|
return
|
|
}
|
|
httpx.Ok(w, data)
|
|
}
|
|
}
|
|
|
|
// CallMaterialHandler POST /line/call-material(工位终端叫料:选接驳台)
|
|
func CallMaterialHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req struct {
|
|
StationNo int `json:"stationNo"`
|
|
Dock string `json:"dock"`
|
|
OrderNo string `json:"orderNo"`
|
|
Items []logic.CallMaterialItem `json:"items"`
|
|
}
|
|
if err := httpx.ParseJSON(r, &req); err != nil {
|
|
httpx.BadRequest(w, "请求体解析失败")
|
|
return
|
|
}
|
|
production.LogImpersonation(svcCtx, r, "", "/api/internal/line/call-material")
|
|
n, err := logic.New(svcCtx).CallMaterial(r.Context(), req.StationNo, req.Dock, req.OrderNo, production.StationOp(r, ""), req.Items)
|
|
if err != nil {
|
|
httpx.Fail(w, 2406, err.Error())
|
|
return
|
|
}
|
|
httpx.OkMessage(w, "叫料已提交", map[string]any{"count": n})
|
|
}
|
|
}
|