提交
This commit is contained in:
@@ -76,7 +76,7 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodPost, Path: "/api/return-material", Handler: returnMaterialHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/inspection/upload", Handler: inspectionUploadHandler(ctx)},
|
||||
|
||||
// 在制品 / 0-13 上下线建档完工 / BOM 领料 / 追溯(代理 MES 内部 API)
|
||||
// 在制品 / 0-13 上下线建档完工 / 物料清单领料 / 追溯(代理 MES 内部 API)
|
||||
{Method: http.MethodGet, Path: "/api/wip", Handler: wipHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/bom", Handler: bomHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/order/query", Handler: orderQueryHandler(ctx)},
|
||||
|
||||
@@ -63,7 +63,7 @@ func bomHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// orderQueryHandler GET /api/order/query?orderNo= —— 代理 MES /api/internal/order/query。
|
||||
// 上线建档选工单后带出产品编码/名称(用于查 BOM 应领料)。
|
||||
// 上线建档选工单后带出产品编码/名称(用于查物料清单应领料)。
|
||||
func orderQueryHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
params := url.Values{}
|
||||
|
||||
@@ -2,11 +2,16 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"embed"
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
@@ -48,12 +53,50 @@ func openBrowser(url string) {
|
||||
}
|
||||
}
|
||||
|
||||
// logRuntimeBinaryFingerprint 在启动早期打印当前运行 EXE 的指纹(真实路径/大小/MD5/修改时间),
|
||||
// 走本项目 logx(go-zero)落盘,与业务日志同文件,便于生产机直接翻日志核对运行版本。
|
||||
// 任何环节失败仅记错误日志并继续,绝不中断启动。
|
||||
func logRuntimeBinaryFingerprint() {
|
||||
exePath, err := os.Executable()
|
||||
if err != nil {
|
||||
logx.Errorf("svc: runtime binary fingerprint skipped: os.Executable failed: %v", err)
|
||||
return
|
||||
}
|
||||
realPath, err := filepath.EvalSymlinks(exePath)
|
||||
if err != nil {
|
||||
// 解析软链接失败:降级用原始路径,仅记日志不影响启动
|
||||
logx.Errorf("svc: runtime binary fingerprint: EvalSymlinks failed, fallback to raw path: %v", err)
|
||||
realPath = exePath
|
||||
}
|
||||
info, err := os.Stat(realPath)
|
||||
if err != nil {
|
||||
logx.Errorf("svc: runtime binary fingerprint skipped: os.Stat failed: %v", err)
|
||||
return
|
||||
}
|
||||
f, err := os.Open(realPath)
|
||||
if err != nil {
|
||||
logx.Errorf("svc: runtime binary fingerprint skipped: open failed: %v", err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
h := md5.New()
|
||||
if _, err := io.Copy(h, f); err != nil {
|
||||
logx.Errorf("svc: runtime binary fingerprint skipped: read failed: %v", err)
|
||||
return
|
||||
}
|
||||
logx.Infof("svc: runtime binary fingerprint path=%s size=%d md5=%s modTime=%s",
|
||||
realPath, info.Size(), hex.EncodeToString(h.Sum(nil)), info.ModTime().Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
// 启动指纹:打印当前 EXE 真实路径/大小/MD5/修改时间,便于核对运行版本
|
||||
logRuntimeBinaryFingerprint()
|
||||
|
||||
// 工位号:由服务端配置文件加载(终端不允许修改)。0=上线位、13=下线位为虚拟工位
|
||||
// (PAD 上线建档 / 下线完工),1~12 为物理装配工位;启动时强校验 >= 0(工位数以数据库/配置为准,不写死 12)。
|
||||
if c.Station.StationNo < 0 {
|
||||
|
||||
Reference in New Issue
Block a user