feat: 新增工序签字功能,移除移料指令模块

新增操作工/检验员工序签字功能,支持工艺步骤配置签字要求;删除移料指令相关代码,将移料页签重命名为产线点位(上料/下料);新增成品入库功能及相关权限;优化备料单状态、质量状态逻辑,新增批次序号字段;修复AGV取消后备料单回退状态问题。
This commit is contained in:
SunYF
2026-10-05 20:15:38 +08:00
parent c33acab9c8
commit f1cf57e9b2
181 changed files with 9785 additions and 9699 deletions
+82 -7
View File
@@ -276,7 +276,9 @@ func (s *Service) syncPlansByOrderStatus(ctx context.Context, orderNo, woStatus,
}
// ListDailyPlans 按工单/日期查询日排产
func (s *Service) ListDailyPlans(ctx context.Context, orderNo, planDate string) ([]*ent.DailyPlan, error) {
// sort: "asc" 按排产日期升序(从前到后,默认,满足客户查看习惯) / "desc" 降序(最新在前)。
// 日排产属业务计划表(非录入流水),不受「增量列表倒序」铁律约束,默认按排产日期升序展示。
func (s *Service) ListDailyPlans(ctx context.Context, orderNo, planDate, sort string) ([]*ent.DailyPlan, error) {
q := s.ctx.EntClient.DailyPlan.Query()
if orderNo != "" {
q = q.Where(dailyplan.OrderNo(orderNo))
@@ -284,7 +286,10 @@ func (s *Service) ListDailyPlans(ctx context.Context, orderNo, planDate string)
if planDate != "" {
q = q.Where(dailyplan.PlanDate(planDate))
}
return q.Order(ent.Desc(dailyplan.FieldPlanDate)).All(ctx)
if sort == "desc" {
return q.Order(ent.Desc(dailyplan.FieldPlanDate)).All(ctx)
}
return q.Order(ent.Asc(dailyplan.FieldPlanDate)).All(ctx)
}
// DailyPlanRow 日排产行(附工单工艺组合,供前端派生路线/接驳台展示)
@@ -293,11 +298,38 @@ type DailyPlanRow struct {
FlowCombination []map[string]int `json:"flowCombination"`
}
// ListDailyPlansWithCombination 日排产列表 + 每行附带所属工单的工艺组合
func (s *Service) ListDailyPlansWithCombination(ctx context.Context, orderNo, planDate string) ([]*DailyPlanRow, error) {
plans, err := s.ListDailyPlans(ctx, orderNo, planDate)
// ListDailyPlansPaged 日排产分页列表 + 每行附带所属工单的工艺组合。
// 防内存炸弹:planDateStart/planDateEnd 限定日期窗口(默认今天~今天+30 由前端传);
// page/pageSize 分页(pageSize 上限 200),返回总行数 total 供前端分页。默认按 planDate 升序。
func (s *Service) ListDailyPlansPaged(ctx context.Context, planDateStart, planDateEnd string, page, pageSize int, sort string) ([]*DailyPlanRow, int64, error) {
if page < 1 {
page = 1
}
if pageSize < 1 {
pageSize = 50
}
if pageSize > 200 {
pageSize = 200
}
base := s.ctx.EntClient.DailyPlan.Query()
if planDateStart != "" {
base = base.Where(dailyplan.PlanDateGTE(planDateStart))
}
if planDateEnd != "" {
base = base.Where(dailyplan.PlanDateLTE(planDateEnd))
}
total, err := base.Count(ctx)
if err != nil {
return nil, err
return nil, 0, err
}
if sort == "desc" {
base = base.Order(ent.Desc(dailyplan.FieldPlanDate))
} else {
base = base.Order(ent.Asc(dailyplan.FieldPlanDate))
}
plans, err := base.Limit(pageSize).Offset((page - 1) * pageSize).All(ctx)
if err != nil {
return nil, 0, err
}
orderNos := make([]string, 0, len(plans))
seen := map[string]bool{}
@@ -320,7 +352,50 @@ func (s *Service) ListDailyPlansWithCombination(ctx context.Context, orderNo, pl
for _, p := range plans {
rows = append(rows, &DailyPlanRow{DailyPlan: p, FlowCombination: combByOrder[p.OrderNo]})
}
return rows, nil
return rows, int64(total), nil
}
// UnplannedWorkOrder 未排产工单(供日排产页「未排产」入口展示)
type UnplannedWorkOrder struct {
OrderNo string `json:"orderNo"`
ProductTypeId int `json:"productTypeId"`
Quantity int `json:"quantity"`
DueDate string `json:"dueDate"`
Status string `json:"status"`
}
// ListUnplannedWorkOrders 工单状态 ∈ {CREATED,RELEASED,IN_PROGRESS} 且日排产表无任何记录的工单。
// 用于日排产页顶部「有 N 个工单尚未排产」入口;每次进入页面查询一次即可(前端缓存 60s)。
func (s *Service) ListUnplannedWorkOrders(ctx context.Context) ([]*UnplannedWorkOrder, error) {
wos, err := s.ctx.EntClient.WorkOrder.Query().
Where(workorder.StatusIn("CREATED", "RELEASED", "IN_PROGRESS")).All(ctx)
if err != nil {
return nil, err
}
planned := map[string]bool{}
if ps, e := s.ctx.EntClient.DailyPlan.Query().Select(dailyplan.FieldOrderNo).All(ctx); e == nil {
for _, p := range ps {
planned[p.OrderNo] = true
}
}
out := make([]*UnplannedWorkOrder, 0, len(wos))
for _, wo := range wos {
if planned[wo.WorkOrderNo] {
continue
}
due := ""
if wo.DueDate != nil {
due = wo.DueDate.Format("2006-01-02")
}
out = append(out, &UnplannedWorkOrder{
OrderNo: wo.WorkOrderNo,
ProductTypeId: wo.ProductTypeId,
Quantity: wo.Quantity,
DueDate: due,
Status: wo.Status,
})
}
return out, nil
}
// DeleteDailyPlan 删除一条日排产记录