提交
This commit is contained in:
@@ -52,7 +52,7 @@ type FlowVO struct {
|
||||
|
||||
// ListFlows 查询工艺流程(可按工位号过滤:只认「工位绑定」页的绑定关系 station.flow_id;
|
||||
// pp 非空时按引用该工艺的产品工艺名称反查过滤)。page>0 时真分页返回 map{total,list,page,pageSize}(管理页用);page=0 全量数组(工位终端兼容)
|
||||
func (s *Service) ListFlows(ctx context.Context, stationNo int, pp string, page, pageSize int) (any, error) {
|
||||
func (s *Service) ListFlows(ctx context.Context, stationNo int, pp, name, status string, stepMin, page, pageSize int) (any, error) {
|
||||
q := s.ctx.EntClient.ProcessFlow.Query().
|
||||
Order(ent.Asc(processflow.FieldID))
|
||||
flows, err := q.All(ctx)
|
||||
@@ -82,6 +82,14 @@ func (s *Service) ListFlows(ctx context.Context, stationNo int, pp string, page,
|
||||
continue
|
||||
}
|
||||
}
|
||||
// 名称模糊过滤(大小写无关)
|
||||
if name != "" && !strings.Contains(strings.ToLower(f.Name), strings.ToLower(name)) {
|
||||
continue
|
||||
}
|
||||
// 状态过滤(ACTIVE/INACTIVE,空=全部)
|
||||
if status != "" && f.Status != status {
|
||||
continue
|
||||
}
|
||||
vo := &FlowVO{
|
||||
Id: f.ID, Name: f.Name,
|
||||
PdfFile: f.PdfFile, Status: f.Status, Remark: f.Remark,
|
||||
@@ -93,6 +101,10 @@ func (s *Service) ListFlows(ctx context.Context, stationNo int, pp string, page,
|
||||
if vo.ProductProcesses = ppNames[f.ID]; vo.ProductProcesses == nil {
|
||||
vo.ProductProcesses = []string{}
|
||||
}
|
||||
// 工序数下限过滤(stepMin>0 时只保留工序数≥阈值者)
|
||||
if stepMin > 0 && len(vo.Steps) < stepMin {
|
||||
continue
|
||||
}
|
||||
// 产品工艺反查过滤(模糊,大小写无关)
|
||||
if pp != "" && !ppContainsFold(vo.ProductProcesses, pp) {
|
||||
continue
|
||||
@@ -331,12 +343,6 @@ func (s *Service) SaveStation(ctx context.Context, req StationReq, operator stri
|
||||
ve.Add("name", "请填写工位名称", "在「工位名称」输入框填写名称后保存")
|
||||
}
|
||||
stype := "LINE"
|
||||
if req.StationType != nil {
|
||||
stype = *req.StationType
|
||||
if stype != "LINE" && stype != "OFFLINE" {
|
||||
ve.Add("stationType", "工位类型仅支持 线上位(LINE)/线下位(OFFLINE)", "类型改为 LINE(连 PLC)或 OFFLINE(不连 PLC)")
|
||||
}
|
||||
}
|
||||
if req.FlowId != nil && *req.FlowId > 0 {
|
||||
flow, fErr := s.ctx.EntClient.ProcessFlow.Get(ctx, *req.FlowId)
|
||||
if fErr != nil {
|
||||
@@ -368,14 +374,6 @@ func (s *Service) SaveStation(ctx context.Context, req StationReq, operator stri
|
||||
}
|
||||
// 更新分支:字段错误 + 规则3守卫(托盘在位/在途指令)全部收集,一次性返回
|
||||
ve := verr.New()
|
||||
if req.StationType != nil {
|
||||
t := *req.StationType
|
||||
if t != "LINE" && t != "OFFLINE" {
|
||||
ve.Add("stationType", "工位类型仅支持 线上位(LINE)/线下位(OFFLINE)", "类型改为 LINE(连 PLC)或 OFFLINE(不连 PLC)")
|
||||
} else if st.IsBuiltin && t != st.StationType {
|
||||
ve.Add("stationType", "内置工位不允许修改工位类型", "内置工位对应实体产线固定位置(连 PLC、按顺序流转),只能改名称/绑定/终端页签")
|
||||
}
|
||||
}
|
||||
// 仅改名称:flowId 不传(nil)保留原绑定;0=解绑;>0=绑定指定启用流程。
|
||||
// 规则3(2026-10-20 拍板,2026-10-20 下午改 fail-closed→fail-open):改绑定关系(含解绑)前,
|
||||
// 过「在途指令/托盘在位」双检(两条同时收集,不串行)。
|
||||
@@ -420,14 +418,8 @@ if req.FlowId != nil {
|
||||
if err := ve.OrNil(); err != nil {
|
||||
return err
|
||||
}
|
||||
upd := s.ctx.EntClient.Station.UpdateOneID(st.ID).SetName(req.Name)
|
||||
if req.StationType != nil {
|
||||
t := *req.StationType
|
||||
if !st.IsBuiltin {
|
||||
upd.SetStationType(t)
|
||||
}
|
||||
}
|
||||
if req.FlowId != nil {
|
||||
upd := s.ctx.EntClient.Station.UpdateOneID(st.ID).SetName(req.Name)
|
||||
if req.FlowId != nil {
|
||||
upd.SetFlowId(bindFlow) // 0=解绑
|
||||
}
|
||||
// 终端可见页签:传 nil=不改;传空数组=清空(全部显示);传列表=按配置显示
|
||||
|
||||
Reference in New Issue
Block a user