docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"bj_power_mes/ent/alertrule"
|
||||
"bj_power_mes/ent/permission"
|
||||
"bj_power_mes/ent/role"
|
||||
"bj_power_mes/ent/station"
|
||||
@@ -87,9 +88,8 @@ func (s *Service) Seed(ctx context.Context) error {
|
||||
{"produce.material", "备料单", "MENU", "/material-request"},
|
||||
{"produce.qty", "数量不符处理", "MENU", "/qty-report"},
|
||||
{"produce.plc", "工位组合下发", "MENU", "/plc-send"},
|
||||
{"produce.processflow", "工艺流程", "MENU", "/process-flow"},
|
||||
{"produce.productprocess", "产品工艺", "MENU", "/product-process"},
|
||||
{"produce.station", "关联工位", "MENU", "/station"}, {"produce.performance", "绩效报表", "MENU", "/performance"},
|
||||
{"produce.processflow", "工艺", "MENU", "/process-flow"},
|
||||
{"produce.station", "工位绑定", "MENU", "/station"}, {"produce.performance", "绩效报表", "MENU", "/performance"},
|
||||
{"produce.dock", "接驳台维护", "MENU", "/dock"},
|
||||
{"produce.trace", "工件追溯", "MENU", "/trace"},
|
||||
// 虚拟工位作业:虚拟工位(如包装等无终端硬件的工位)由人工在 MES 后台(手机/电脑)完成报工,
|
||||
@@ -113,18 +113,29 @@ func (s *Service) Seed(ctx context.Context) error {
|
||||
{"sys.attachment", "附件中心", "MENU", "/attachment"},
|
||||
}
|
||||
for _, m := range menus {
|
||||
if s.ctx.EntClient.Permission.Query().Where(permission.Code(m.code)).ExistX(ctx) {
|
||||
exist, err := s.ctx.EntClient.Permission.Query().Where(permission.Code(m.code)).First(ctx)
|
||||
if err == nil && exist != nil {
|
||||
// 已存在:幂等同步菜单名(如「关联工位」→「工位绑定」术语更新),路径/类型不动
|
||||
if exist.Name != m.name {
|
||||
_ = exist.Update().SetName(m.name).Exec(ctx)
|
||||
}
|
||||
continue
|
||||
}
|
||||
_ = s.ctx.EntClient.Permission.Create().
|
||||
SetCode(m.code).SetName(m.name).SetType(m.typ).SetPath(m.path).Exec(ctx)
|
||||
}
|
||||
|
||||
// BOM 已删除(物料跟着工单走):清理历史「产品物料清单」菜单与按钮权限
|
||||
// 物料清单已删除(物料跟着工单走):清理历史「产品物料清单」菜单与按钮权限
|
||||
for _, dead := range []string{"produce.bom", "produce.bom:edit"} {
|
||||
_, _ = s.ctx.EntClient.Permission.Delete().Where(permission.Code(dead)).Exec(ctx)
|
||||
}
|
||||
|
||||
// 「产品工艺」已并入「工艺」页的首个 tab(2026-10-10):移除其独立菜单权限(MENU),
|
||||
// 但保留 produce.productprocess:add/edit/delete 按钮权限(tab 内新增/编辑/删除按钮仍依赖它们做 can() 校验)。
|
||||
for _, dead := range []string{"produce.productprocess"} {
|
||||
_, _ = s.ctx.EntClient.Permission.Delete().Where(permission.Code(dead)).Exec(ctx)
|
||||
}
|
||||
|
||||
// 3.1 按钮级权限(块2):前端按钮 + 后端接口 双重校验
|
||||
// parent = 所属菜单权限码:每个按钮显式声明挂在哪个菜单下,前端据此组装权限树,
|
||||
// 不再用 code.startsWith(菜单+':') 这类前缀通配推断。
|
||||
@@ -210,9 +221,33 @@ func (s *Service) Seed(ctx context.Context) error {
|
||||
seedStations(ctx, s)
|
||||
// 5. 接驳台主数据(真源在 MES,2026-09-21 自 WMS 迁入);系统预置只读
|
||||
seedDocks(ctx, s)
|
||||
// 6. 预警规则常用占位(遗留5 告警框架第一阶段):只插缺失行,enabled=false / threshold=0,
|
||||
// 即"占位不启用"——由实施在预警中心按需改阈值/启用,绝不默认触发
|
||||
seedAlertRules(ctx, s)
|
||||
return nil
|
||||
}
|
||||
|
||||
// seedAlertRules 预警规则占位(幂等):按 type 幂等插入,已有行(含人工改过的阈值/启用态)一律不动。
|
||||
// 常用类型:torque_ng=拧紧扭矩不合格 / inspection_ng=检验不合格 / inventory_low=库存低于阈值 / task_overdue=任务超期。
|
||||
func seedAlertRules(ctx context.Context, s *Service) {
|
||||
placeholders := []struct{ typ, name string }{
|
||||
{"torque_ng", "拧紧扭矩不合格预警"},
|
||||
{"inspection_ng", "检验不合格预警"},
|
||||
{"inventory_low", "库存低于阈值预警"},
|
||||
{"task_overdue", "任务超期预警"},
|
||||
}
|
||||
for _, p := range placeholders {
|
||||
if ok, _ := s.ctx.EntClient.AlertRule.Query().Where(alertrule.Type(p.typ)).Exist(ctx); ok {
|
||||
continue
|
||||
}
|
||||
if _, err := s.ctx.EntClient.AlertRule.Create().
|
||||
SetName(p.name).SetType(p.typ).SetThreshold(0).
|
||||
SetEnabled(false).SetCreatedBy("seed").Save(ctx); err != nil {
|
||||
continue // 单条失败不阻断其余占位
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// seedDocks 接驳台主数据:DOCK01~20 对应工位1~10(每工位2个,AGV R1/R2 点位),DOCK21 库房收货。
|
||||
// 系统预置只读主数据(不提供增删改),与工位种子同源一次性写入。
|
||||
func seedDocks(ctx context.Context, s *Service) {
|
||||
@@ -247,7 +282,7 @@ func seedStations(ctx context.Context, s *Service) {
|
||||
// 属系统内置只读主数据(同 WMS 接驳台),故由种子初始化。12 个装配工位(1~10 带接驳台,11/12 产线末端无接驳台);
|
||||
// 工位数量以数据库为准,要 13 个就往 station 表插一行。
|
||||
// 工艺流程/工序步骤不在此预置:流程可在「工艺流程」页新建/编辑/删除/启停,是用户可维护的业务数据,
|
||||
// 由实施按产品工艺自建、并在「关联工位」页绑定到工位(station.flow_id),不硬编码进种子。
|
||||
// 由实施按产品工艺自建、并在「工位绑定」页绑定到工位(station.flow_id),不硬编码进种子。
|
||||
for i := 1; i <= 12; i++ {
|
||||
if _, err := s.ctx.EntClient.Station.Query().Where(station.StationNo(i)).First(ctx); err != nil {
|
||||
_, _ = s.ctx.EntClient.Station.Create().
|
||||
@@ -337,7 +372,7 @@ func migrateLegacySysRbac(ctx context.Context, s *Service) {
|
||||
}
|
||||
|
||||
// migrateLegacyRoute 清理已删除的「工艺路线」模块残留(幂等,可重复执行):
|
||||
// 产线定义已简化为「关联工位(station.flow_id) + 工位号 1→12 顺序 + 工单工位组合」,
|
||||
// 产线定义已简化为「工位绑定(station.flow_id) + 工位号 1→12 顺序 + 工单工位组合」,
|
||||
// 工艺路线/路线段整块删除,故需从存量角色的 permissionCodes 中摘除路线权限码,
|
||||
// 并删除对应的菜单/按钮权限定义行,避免菜单树里留下失效入口。
|
||||
func migrateLegacyRoute(ctx context.Context, s *Service) {
|
||||
|
||||
Reference in New Issue
Block a user