feat: 完成产线MES系统全流程功能迭代与优化
本提交完成了多个核心模块的功能完善与业务对齐: 1. 工位终端:固定工位配置、移除自选工位逻辑、适配配置化工位号 2. MES核心:重构工位组合逻辑、新增工单/流程状态管理、补全报工/追溯逻辑 3. WMS客户端:新增修改密码功能、优化帮助弹窗逻辑 4. 文档与权限:补充完整操作手册、统一菜单名称与权限描述 5. 修复多业务校验:排产数量校验、工单状态校验、工位绑定规则
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/processstep"
|
||||
"bj_power_mes/ent/processflow"
|
||||
"bj_power_mes/ent/stepcriterion"
|
||||
"bj_power_mes/ent/torquerecord"
|
||||
"bj_power_mes/ent/workpieceprocess"
|
||||
@@ -122,32 +122,19 @@ type CriterionVO struct {
|
||||
Max *float64 `json:"max"`
|
||||
}
|
||||
|
||||
// ListProcessSteps 查询某工序的步骤模板(含考核标准),供手动报工页动态渲染参数输入
|
||||
func (s *Service) ListProcessSteps(ctx context.Context, processCode int) ([]*ProcessStepTemplate, error) {
|
||||
steps, err := s.ctx.EntClient.ProcessStep.Query().
|
||||
Where(processstep.ProcessCode(processCode)).
|
||||
Order(ent.Asc(processstep.FieldSeq)).All(ctx)
|
||||
// ListStationSteps 按工位号加载该工位「启用」工艺流程的工序步骤(含考核标准)。
|
||||
// 手动报工页:选工位 → 自动带出该工位的工序步骤。
|
||||
func (s *Service) ListStationSteps(ctx context.Context, stationNo int) ([]*ProcessStepTemplate, error) {
|
||||
if stationNo < 1 || stationNo > 12 {
|
||||
return []*ProcessStepTemplate{}, nil
|
||||
}
|
||||
flow, err := s.ctx.EntClient.ProcessFlow.Query().
|
||||
Where(processflow.ProcessCode(stationNo), processflow.Status("ACTIVE")).First(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// 该工位未配置启用的工艺流程:返回空模板(前端提示)
|
||||
return []*ProcessStepTemplate{}, nil
|
||||
}
|
||||
out := make([]*ProcessStepTemplate, 0, len(steps))
|
||||
for _, st := range steps {
|
||||
t := &ProcessStepTemplate{
|
||||
ID: st.ID, ProcessCode: st.ProcessCode, Seq: st.Seq,
|
||||
Name: st.Name, CollectType: st.CollectType, IsTorque: st.IsTorque,
|
||||
Remark: st.Remark, Criteria: []CriterionVO{},
|
||||
}
|
||||
crits, _ := s.ctx.EntClient.StepCriterion.Query().
|
||||
Where(stepcriterion.StepId(st.ID)).All(ctx)
|
||||
for _, c := range crits {
|
||||
t.Criteria = append(t.Criteria, CriterionVO{
|
||||
ID: c.ID, Name: c.Name, Unit: c.Unit, Logic: c.Logic,
|
||||
Target: c.Target, Min: c.Min, Max: c.Max,
|
||||
})
|
||||
}
|
||||
out = append(out, t)
|
||||
}
|
||||
return out, nil
|
||||
return s.flowSteps(ctx, flow.ID, flow.ProcessCode), nil
|
||||
}
|
||||
|
||||
// StepItemReq 一次保存的一个步骤(含其考核标准)
|
||||
@@ -161,68 +148,3 @@ type StepItemReq struct {
|
||||
Remark string `json:"remark"`
|
||||
Criteria []CriterionVO `json:"criteria"`
|
||||
}
|
||||
|
||||
// SaveProcessSteps 覆盖式保存某工序的步骤模板及考核标准(供"工艺参数"维护页调用)
|
||||
func (s *Service) SaveProcessSteps(ctx context.Context, steps []StepItemReq, operator string) error {
|
||||
for _, st := range steps {
|
||||
if st.ProcessCode <= 0 || st.Name == "" {
|
||||
continue
|
||||
}
|
||||
var stepID int
|
||||
if st.ID > 0 {
|
||||
upd := s.ctx.EntClient.ProcessStep.UpdateOneID(st.ID).
|
||||
SetSeq(st.Seq).SetName(st.Name).SetCollectType(st.CollectType).
|
||||
SetIsTorque(st.IsTorque).SetRemark(st.Remark)
|
||||
_, err := upd.Save(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stepID = st.ID
|
||||
} else {
|
||||
rec, err := s.ctx.EntClient.ProcessStep.Create().
|
||||
SetProcessCode(st.ProcessCode).SetSeq(st.Seq).SetName(st.Name).
|
||||
SetCollectType(st.CollectType).SetIsTorque(st.IsTorque).SetRemark(st.Remark).Save(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stepID = rec.ID
|
||||
}
|
||||
// 覆盖式重建该步骤的考核标准
|
||||
_, _ = s.ctx.EntClient.StepCriterion.Delete().Where(stepcriterion.StepId(stepID)).Exec(ctx)
|
||||
for _, c := range st.Criteria {
|
||||
if c.Name == "" || c.Logic == "" || c.Logic == "NONE" {
|
||||
continue
|
||||
}
|
||||
b := s.ctx.EntClient.StepCriterion.Create().
|
||||
SetStepId(stepID).SetName(c.Name).SetUnit(c.Unit).SetLogic(c.Logic).
|
||||
SetTarget(c.Target)
|
||||
if c.Min != nil {
|
||||
b = b.SetMin(*c.Min)
|
||||
}
|
||||
if c.Max != nil {
|
||||
b = b.SetMax(*c.Max)
|
||||
}
|
||||
if err := b.Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
s.ctx.EventLog.Write(ctx, "process.steps.save", "", operator, "process_step", "", "维护工艺参数", map[string]any{"count": len(steps)})
|
||||
return nil
|
||||
}
|
||||
|
||||
// AllProcessSteps 查询全部工序的步骤模板(含 12 道工序),供维护页按工序分组展示
|
||||
func (s *Service) AllProcessSteps(ctx context.Context, processCode int) ([]*ProcessStepTemplate, error) {
|
||||
if processCode > 0 {
|
||||
return s.ListProcessSteps(ctx, processCode)
|
||||
}
|
||||
out := []*ProcessStepTemplate{}
|
||||
for code := 1; code <= 12; code++ {
|
||||
sub, err := s.ListProcessSteps(ctx, code)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, sub...)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user