feat: 重构 AGV 对接与在制品查询,新增 PLC 手动监控功能

This commit is contained in:
SunYF
2026-10-17 17:49:47 +08:00
parent f65a52d9e1
commit f743cf21fb
96 changed files with 6130 additions and 1781 deletions
+17
View File
@@ -77,6 +77,23 @@ func (s *Service) ListPoints(ctx context.Context) ([]map[string]any, error) {
return out, nil
}
// CheckPointFree 点位可占用预检(建档/完工落账前调用,避免半量副作用):
// 点位必须存在且未被其它工件占用(同一工件幂等放行);pointNo 为空=未选点位,直接放行。
func (s *Service) CheckPointFree(ctx context.Context, pointNo, sn string) error {
pointNo = strings.TrimSpace(pointNo)
if pointNo == "" {
return nil
}
pt, err := s.ctx.EntClient.LinePoint.Query().Where(linepoint.PointNo(pointNo)).First(ctx)
if err != nil {
return errors.New("工件位置不存在:" + pointNo)
}
if pt.Occupied && pt.CurrentSn != strings.TrimSpace(sn) {
return errors.New("工件位置 " + pointNo + " 已被工件 " + pt.CurrentSn + " 占用,请改选空闲点位")
}
return nil
}
// OccupyPoint 点位人工记账(唯一事实源维护入口)。
// action=IN :上料/占位,把工件 SN 记到该点位(点位被其它工件占用时报错;同一工件幂等放行)。
// action=OUT :下料/释放,清空该点位(传入 sn 时校验点位当前就是该工件)。