55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package handler
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"strconv"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"bj_power_mes/common/httpx"
|
||
|
|
"bj_power_mes/internal/logic"
|
||
|
|
"bj_power_mes/internal/svc"
|
||
|
|
)
|
||
|
|
|
||
|
|
// StationTerminalStateInternalHandler 查某工位终端状态(WMS 代退料前置条件②数据源,内部通道)。
|
||
|
|
func StationTerminalStateInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
||
|
|
no, err := strconv.Atoi(strings.TrimSpace(r.URL.Query().Get("stationNo")))
|
||
|
|
if err != nil || no <= 0 {
|
||
|
|
httpx.BadRequest(w, "stationNo 必填")
|
||
|
|
return
|
||
|
|
}
|
||
|
|
view, derr := logic.New(svcCtx).GetTerminalState(r.Context(), no)
|
||
|
|
if derr != nil {
|
||
|
|
httpx.Fail(w, 2502, derr.Error())
|
||
|
|
return
|
||
|
|
}
|
||
|
|
httpx.Ok(w, view)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// TerminalStateListHandler MES 管理页:所有工位终端状态(JWT 保护)。
|
||
|
|
func TerminalStateListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
||
|
|
rows, err := logic.New(svcCtx).ListTerminalStates(r.Context())
|
||
|
|
if err != nil {
|
||
|
|
httpx.Fail(w, 2503, err.Error())
|
||
|
|
return
|
||
|
|
}
|
||
|
|
httpx.Ok(w, rows)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// TerminalEventListHandler MES 管理页:状态变化流水(JWT 保护)。
|
||
|
|
func TerminalEventListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
||
|
|
no, _ := strconv.Atoi(strings.TrimSpace(r.URL.Query().Get("stationNo")))
|
||
|
|
limit, _ := strconv.Atoi(strings.TrimSpace(r.URL.Query().Get("limit")))
|
||
|
|
rows, err := logic.New(svcCtx).ListTerminalEvents(r.Context(), no, limit)
|
||
|
|
if err != nil {
|
||
|
|
httpx.Fail(w, 2504, err.Error())
|
||
|
|
return
|
||
|
|
}
|
||
|
|
httpx.Ok(w, rows)
|
||
|
|
}
|
||
|
|
}
|