新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
62 lines
1.9 KiB
Go
62 lines
1.9 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)
|
|
}
|
|
}
|