feat: 大屏新增虚拟工位滚动栏与多订单轮播,附件表增加删除原因及彻底清除留痕字段

This commit is contained in:
SunYF
2026-10-29 18:16:53 +08:00
parent 4d3c4e2c3a
commit 11dbdaae75
75 changed files with 6801 additions and 965 deletions
@@ -3,6 +3,7 @@ package production
import (
"net/http"
"regexp"
"strconv"
"strings"
"bj_power_mes/common/httpx"
@@ -15,6 +16,8 @@ import (
// 工位维护 / 排产推荐 / AGV 通讯均查本表;仓库不再维护接驳台、也不给接驳台派任务。
// 2026-10-17(块 E.2)开放维护:接驳台并入「产线管理」页 tab3,提供增/改/删/启停。
// has_pallet / pallet_ref 为 PLC 传感器实时占用态,不属人工维护字段,CRUD 一律不触碰。
// 接驳台↔工位为硬件级对应关系(DOCKnn → 工位 (nn+1)/2,同 seed 公式),stationNo 由 dockCode 派生,
// 不属人工维护字段,CRUD 一律不接收 stationNo(2026-10-28 裁定:硬件级对应关系不允许编辑)。
// dockRow 接驳台返回 DTO(显式 json 标签,避免 ent omitempty 吞掉 hasPallet=false)。
type dockRow struct {
@@ -109,14 +112,13 @@ func ListDocksInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
// ---------- 接驳台维护(块 E.2:并入产线管理页,开放增/改/删/启停) ----------
// dockEditReq 接驳台维护请求体(id=0 为新增;has_pallet/pallet_ref 为 PLC 实时态,不接受人工维护)。
// dockEditReq 接驳台维护请求体(id=0 为新增;has_pallet/pallet_ref 为 PLC 实时态、stationNo 为硬件派生,均不接受人工维护)。
type dockEditReq struct {
ID int `json:"id"`
DockCode string `json:"dockCode"`
Name string `json:"name"`
DockType string `json:"dockType"`
StationNo int `json:"stationNo"`
Status string `json:"status"`
ID int `json:"id"`
DockCode string `json:"dockCode"`
Name string `json:"name"`
DockType string `json:"dockType"`
Status string `json:"status"`
}
var dockCodeRe = regexp.MustCompile(`^[A-Z0-9]{2,16}$`)
@@ -151,11 +153,24 @@ func validateDock(w http.ResponseWriter, ctx *svc.ServiceContext, r *http.Reques
return "", 0, false
}
if typ == "line" {
if req.StationNo < 1 || req.StationNo > 12 {
httpx.Fail(w, 3114, "产线类接驳台必须绑定工位(工位号 1~12)")
// 接驳台↔工位为硬件级对应关系,stationNo 由 dockCode 派生,不接受人工输入:
// 产线接驳台编码须为 DOCKnn(如 DOCK05),nn 为末两位编号,
// 推导 工位 = (nn+1)/2(DOCK01/02→工位1 … DOCK19/20→工位10,同 seed 公式)。
if !strings.HasPrefix(code, "DOCK") {
httpx.Fail(w, 3114, "产线类接驳台编码须以 DOCK 开头(如 DOCK05),以便推导所属工位")
return "", 0, false
}
rest := code[len("DOCK"):]
if !isAllDigits(rest) {
httpx.Fail(w, 3114, "产线类接驳台编码须为 DOCK 加数字(如 DOCK05)")
return "", 0, false
}
n, _ := strconv.Atoi(rest)
stationNo = (n + 1) / 2
if stationNo < 1 || stationNo > 12 {
httpx.Fail(w, 3114, "接驳台编码推导出的工位号超出范围(1~12):"+code)
return "", 0, false
}
stationNo = req.StationNo
}
// 编码唯一(大小写不敏感;编辑时排除自身)
q := ctx.EntClient.Dock.Query().Where(dock.DockCodeEqualFold(code))
@@ -174,6 +189,19 @@ func validateDock(w http.ResponseWriter, ctx *svc.ServiceContext, r *http.Reques
return code, stationNo, true
}
// isAllDigits 判断字符串是否全为数字(运行期不使用正则)。
func isAllDigits(s string) bool {
if s == "" {
return false
}
for i := 0; i < len(s); i++ {
if s[i] < '0' || s[i] > '9' {
return false
}
}
return true
}
// SaveDockHandler POST /docks 新增或修改接驳台(id=0 为新增)。
func SaveDockHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {