feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段
- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统 - 为BomItem实体添加relatedStandard字段及相关CRUD方法 - 为InspectionRecord实体添加reportNo、materialCode、materialName等字段 - 更新ent schema确保新字段的验证和默认值设置 - 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
@@ -94,7 +94,7 @@ func pdfQueryHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// pdfOpenHandler GET /pdfopen/<name>(免鉴权,供 iframe 直链)
|
||||
// pdfOpenHandler GET /pdfopen/<name>(免鉴权,供 iframe 直链;仅单层文件名)
|
||||
func pdfOpenHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
raw := strings.TrimPrefix(r.URL.EscapedPath(), "/pdfopen/")
|
||||
@@ -107,14 +107,26 @@ func pdfOpenHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// forwardFile 校验单段文件名后拉取 MES 文件流并原样转发;优先命中本地预缓存。
|
||||
// pdfViewHandler GET /pdfview?name=<encoded>(免鉴权,注册在鉴权中间件之前的路由组)。
|
||||
// 以 query 传文件名,天然支持 MES 落盘的「日期子目录/文件名」(如 2026-09-16/xxx.pdf),
|
||||
// 供工艺流程 PDF 与工序步骤图纸附件(Item J)统一使用。
|
||||
func pdfViewHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
forwardFile(w, ctx.Mes, ctx.PdfCache, strings.TrimSpace(r.URL.Query().Get("name")))
|
||||
}
|
||||
}
|
||||
|
||||
// forwardFile 校验文件名后拉取 MES 文件流并原样转发;优先命中本地预缓存。
|
||||
// 允许「单层日期子目录/文件名」(MES 上传落盘格式),拒绝路径穿越与多级/绝对路径。
|
||||
func forwardFile(w http.ResponseWriter, mesc *mes.Client, cache *pdfcache.Cache, name string) {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
fail(w, http.StatusBadRequest, "缺少文件名")
|
||||
return
|
||||
}
|
||||
if strings.ContainsAny(name, `/\`) || name == "." || name == ".." || strings.Contains(name, "..") {
|
||||
if strings.Contains(name, "..") || strings.ContainsAny(name, `\`) ||
|
||||
strings.HasPrefix(name, "/") || strings.HasSuffix(name, "/") ||
|
||||
strings.Count(name, "/") > 1 || name == "." {
|
||||
fail(w, http.StatusBadRequest, "非法文件名")
|
||||
return
|
||||
}
|
||||
@@ -129,8 +141,8 @@ func forwardFile(w http.ResponseWriter, mesc *mes.Client, cache *pdfcache.Cache,
|
||||
f.Close()
|
||||
}
|
||||
|
||||
// 2) 回源 MES 下载
|
||||
body, header, err := mesc.Get("/api/internal/files/"+url.PathEscape(name), nil)
|
||||
// 2) 回源 MES 下载(内部文件接口按 query 参数 name 读取,支持日期子目录)
|
||||
body, header, err := mesc.Get("/api/internal/files", url.Values{"name": {name}})
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadGateway, "工艺文件获取失败:"+errString(err))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user