refactor: 统一术语BOM为物料清单并补充工位扩展能力

主要变更:
1.  后端:重构工位管理逻辑,新增工位自定义扩展能力,将工位号上限调整为999并支持14+虚拟工位
2.  前后端:全量替换"BOM"术语为"物料清单",包括提示语、注释和文档
3.  WMS模块:新增AGV任务取消接口与前端页面,对接海康RCS取消任务逻辑
4.  权限与种子数据:新增工位新增权限并更新权限配置
5.  修复错误校验逻辑,优化AGV客户端签名与请求处理
This commit is contained in:
SunYF
2026-09-17 19:41:00 +08:00
parent e31b85e87a
commit bf3a408839
20 changed files with 276 additions and 52 deletions
+39 -3
View File
@@ -278,14 +278,50 @@ func (s *Service) ListStations(ctx context.Context) ([]*StationVO, error) {
return out, nil
}
// SaveStation 维护工位:只改名称/绑定流程。工位主数据由数据库维护,本接口不新增工位。
// SaveStation 维护工位:
// - 工位号已存在 → 只改名称/类型/绑定流程(不增删工位)
// - 工位号不存在 → 新增工位;新增的工位号由用户自定义,允许扩展 14、15…(虚拟/物理均可)
//
// 工位数量以数据库为准,前端下拉随 station 表自动增减;虚拟工位(0/13/14...)不连 PLC、仅记录。
func (s *Service) SaveStation(ctx context.Context, req StationReq, operator string) error {
if req.StationNo <= 0 {
if req.StationNo < 0 {
return errors.New("工位号非法(需 ≥ 0")
}
if req.StationNo == 0 && req.Name == "" {
return errors.New("工位号非法")
}
st, err := s.ctx.EntClient.Station.Query().Where(station.StationNo(req.StationNo)).First(ctx)
if err != nil {
return fmt.Errorf("工位 %d 不存在,请先在工位主数据中维护", req.StationNo)
// 新增工位:工位号不存在即创建
if req.Name == "" {
return errors.New("请填写工位名称")
}
stype := "LINE"
if req.StationType != nil {
stype = *req.StationType
if stype != "LINE" && stype != "OFFLINE" {
return errors.New("工位类型仅支持 LINE/OFFLINE")
}
}
cr := s.ctx.EntClient.Station.Create().
SetStationNo(req.StationNo).SetName(req.Name).SetStationType(stype).SetStatus("ENABLED")
if req.FlowId != nil && *req.FlowId > 0 {
flow, fErr := s.ctx.EntClient.ProcessFlow.Get(ctx, *req.FlowId)
if fErr != nil {
return errors.New("所选工艺流程不存在")
}
if flow.Status != "ACTIVE" {
return errors.New("该工艺流程已停用,请先启用后再绑定工位")
}
cr.SetFlowId(*req.FlowId)
}
created, cErr := cr.Save(ctx)
if cErr != nil {
return cErr
}
s.ctx.EventLog.Write(ctx, "station.create", "", operator, "station", "",
"新增工位", map[string]any{"stationNo": created.StationNo, "name": created.Name})
return nil
}
// 仅改名称:flowId 不传(nil)保留原绑定;0=解绑;>0=绑定指定启用流程
upd := s.ctx.EntClient.Station.UpdateOneID(st.ID).SetName(req.Name)