feat: 新增产品工艺管理与工序审核功能
- 新增产品工艺(product_process)及明细(product_process_item)数据模型 - 新增工序审核开关(need_audit)与审核角色(audit_role)字段 - 新增待审核签字页面与路由 - 优化 WMS/MES 接口交互,增加业务错误处理与友好提示 - 补充库存过滤逻辑,避免返回已出库 SN 数据 - 调整默认查询时间范围为近一个月,优化用户体验
This commit is contained in:
@@ -43,12 +43,14 @@ type FlowVO struct {
|
||||
Remark string `json:"remark"`
|
||||
Stations []int `json:"stations"`
|
||||
Steps []*ProcessStepTemplate `json:"steps"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
// 只读反查:引用本工艺的产品工艺名称列表(产品工艺明细实时反查)
|
||||
ProductProcesses []string `json:"productProcesses"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
// ListFlows 查询工艺流程(可按工位号过滤:只认「关联工位」页的绑定关系 station.flow_id)
|
||||
// page>0 时真分页返回 map{total,list,page,pageSize}(管理页用);page=0 全量数组(工位终端兼容)
|
||||
func (s *Service) ListFlows(ctx context.Context, stationNo, page, pageSize int) (any, error) {
|
||||
// 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) {
|
||||
q := s.ctx.EntClient.ProcessFlow.Query().
|
||||
Order(ent.Asc(processflow.FieldID))
|
||||
flows, err := q.All(ctx)
|
||||
@@ -62,6 +64,7 @@ func (s *Service) ListFlows(ctx context.Context, stationNo, page, pageSize int)
|
||||
flowToStations[st.FlowId] = append(flowToStations[st.FlowId], st.StationNo)
|
||||
}
|
||||
}
|
||||
ppNames := s.productProcessNamesByFlow(ctx)
|
||||
out := make([]*FlowVO, 0, len(flows))
|
||||
for _, f := range flows {
|
||||
// 过滤:指定工位号时,只返回绑定了该工位的流程
|
||||
@@ -85,6 +88,13 @@ func (s *Service) ListFlows(ctx context.Context, stationNo, page, pageSize int)
|
||||
if list, ok := flowToStations[f.ID]; ok {
|
||||
vo.Stations = list
|
||||
}
|
||||
if vo.ProductProcesses = ppNames[f.ID]; vo.ProductProcesses == nil {
|
||||
vo.ProductProcesses = []string{}
|
||||
}
|
||||
// 产品工艺反查过滤(模糊,大小写无关)
|
||||
if pp != "" && !ppContainsFold(vo.ProductProcesses, pp) {
|
||||
continue
|
||||
}
|
||||
out = append(out, vo)
|
||||
}
|
||||
if page > 0 {
|
||||
@@ -264,6 +274,8 @@ type StationVO struct {
|
||||
Status string `json:"status"`
|
||||
IsBuiltin bool `json:"isBuiltin"`
|
||||
VisibleTabs []string `json:"visibleTabs"`
|
||||
// 只读反查:本工位绑定工艺被哪些产品工艺引用(名称列表)
|
||||
ProductProcesses []string `json:"productProcesses"`
|
||||
}
|
||||
|
||||
func (s *Service) ListStations(ctx context.Context) ([]*StationVO, error) {
|
||||
@@ -276,12 +288,16 @@ func (s *Service) ListStations(ctx context.Context) ([]*StationVO, error) {
|
||||
for _, f := range flows {
|
||||
flowMap[f.ID] = f
|
||||
}
|
||||
ppNames := s.productProcessNamesByFlow(ctx)
|
||||
out := make([]*StationVO, 0, len(stas))
|
||||
for _, st := range stas {
|
||||
vo := &StationVO{Id: st.ID, StationNo: st.StationNo, Name: st.Name, FlowId: st.FlowId, StationType: st.StationType, Status: st.Status, IsBuiltin: st.IsBuiltin, VisibleTabs: st.VisibleTabs}
|
||||
if f, ok := flowMap[st.FlowId]; ok {
|
||||
vo.FlowName = f.Name
|
||||
}
|
||||
if vo.ProductProcesses = ppNames[st.FlowId]; vo.ProductProcesses == nil {
|
||||
vo.ProductProcesses = []string{}
|
||||
}
|
||||
out = append(out, vo)
|
||||
}
|
||||
return out, nil
|
||||
|
||||
Reference in New Issue
Block a user