feat: 完成产线MES系统全流程功能迭代与优化

本提交完成了多个核心模块的功能完善与业务对齐:
1. 工位终端:固定工位配置、移除自选工位逻辑、适配配置化工位号
2. MES核心:重构工位组合逻辑、新增工单/流程状态管理、补全报工/追溯逻辑
3. WMS客户端:新增修改密码功能、优化帮助弹窗逻辑
4. 文档与权限:补充完整操作手册、统一菜单名称与权限描述
5. 修复多业务校验:排产数量校验、工单状态校验、工位绑定规则
This commit is contained in:
SunYF
2026-08-31 12:58:28 +08:00
parent a3145a8bd6
commit ae4c292487
53 changed files with 1475 additions and 912 deletions
+15 -20
View File
@@ -4,12 +4,12 @@ import (
"context"
"strconv"
"bj_power_mes/ent"
"bj_power_mes/ent/permission"
"bj_power_mes/ent/processflow"
"bj_power_mes/ent/processstep"
"bj_power_mes/ent/role"
"bj_power_mes/ent/station"
"bj_power_mes/ent/stationprocess"
"bj_power_mes/ent/user"
"golang.org/x/crypto/bcrypt"
@@ -28,7 +28,7 @@ func (s *Service) Seed(ctx context.Context) error {
if r.code == "OPERATOR" {
codes = []string{
"produce.workorder", "produce.dailyplan", "produce.bom", "produce.material", "produce.scan",
"produce.trace", "produce.torque", "produce.plc", "produce.product", "produce.step",
"produce.trace", "produce.torque", "produce.plc", "produce.product",
"produce.processflow", "produce.station", "produce.performance",
// 按钮级权限(块2
"produce.workorder:add", "produce.workorder:edit", "produce.workorder:delete",
@@ -73,13 +73,12 @@ func (s *Service) Seed(ctx context.Context) error {
{"produce.dailyplan", "日排产", "MENU", "/daily-plan"},
{"produce.bom", "物料清单", "MENU", "/bom"},
{"produce.material", "备料单", "MENU", "/material-request"},
{"produce.plc", "PLC工序下发", "MENU", "/plc-send"},
{"produce.plc", "工位组合下发", "MENU", "/plc-send"},
{"produce.torque", "拧紧查询", "MENU", "/torque"},
{"produce.step", "工艺参数", "MENU", "/process-step"},
{"produce.processflow", "工艺流程", "MENU", "/process-flow"},
{"produce.station", "工位管理", "MENU", "/station"},
{"produce.station", "关联工位", "MENU", "/station"},
{"produce.performance", "绩效报表", "MENU", "/performance"},
{"produce.scan", "扫码报工", "MENU", "/scan"},
{"produce.scan", "手动报工", "MENU", "/scan"},
{"produce.trace", "工件追溯", "MENU", "/trace"},
{"produce.product", "产品类型", "MENU", "/product-type"},
{"sys.inspect", "巡检终端", "MENU", "/inspect"},
@@ -102,7 +101,7 @@ func (s *Service) Seed(ctx context.Context) error {
{"produce.workorder:dailyplan", "工单-日排产", "BUTTON", ""},
{"produce.bom:edit", "物料清单-维护", "BUTTON", ""},
{"produce.material:generate", "备料单-生成", "BUTTON", ""},
{"produce.plc:send", "PLC工序-下发", "BUTTON", ""},
{"produce.plc:send", "工位组合-下发", "BUTTON", ""},
{"produce.product:add", "产品类型-新增", "BUTTON", ""},
{"produce.product:edit", "产品类型-编辑", "BUTTON", ""},
{"produce.product:delete", "产品类型-删除", "BUTTON", ""},
@@ -129,29 +128,25 @@ func (s *Service) Seed(ctx context.Context) error {
SetCode(b.code).SetName(b.name).SetType(b.typ).SetPath(b.path).Exec(ctx)
}
// 4. 12 道工序默认工艺流程 + 工位绑定(流程挂 process_code,工位绑流程)
// 4. 12 个工位默认工艺流程 + 工位绑定(流程挂 process_code,工位绑流程)
seedFlowsAndStations(ctx, s)
// 5. 12 工位 ↔ 工序 派工(工位N 默认做工序N)
for i := 1; i <= 12; i++ {
if s.ctx.EntClient.StationProcess.Query().Where(stationprocess.StationNo(i), stationprocess.ProcessCode(i)).ExistX(ctx) {
continue
}
_ = s.ctx.EntClient.StationProcess.Create().
SetStationNo(i).SetProcessCode(i).SetEffectDate("").Exec(ctx)
}
return nil
}
func seedFlowsAndStations(ctx context.Context, s *Service) {
// 每个工序编号1~12创建默认工艺流程,并为每道工序补默认步骤模板(挂到流程下)
// 每个工1~12若未配置工艺流程,则创建默认流程并绑定;已有流程则跳过
for i := 1; i <= 12; i++ {
flow, err := s.ctx.EntClient.ProcessFlow.Query().
Where(processflow.ProcessCode(i), processflow.Name("工序"+strconv.Itoa(i)+"_默认")).First(ctx)
Where(processflow.ProcessCode(i)).
Order(ent.Asc(processflow.FieldID)).First(ctx)
if err != nil {
flow, _ = s.ctx.EntClient.ProcessFlow.Create().
SetName("工" + strconv.Itoa(i) + "_默认").
SetName("工" + strconv.Itoa(i) + "_默认").
SetProcessCode(i).SetStatus("ACTIVE").SetRemark("默认工艺流程").Save(ctx)
}
if flow == nil {
continue
}
cnt, _ := s.ctx.EntClient.ProcessStep.Query().Where(processstep.FlowId(flow.ID)).Count(ctx)
if cnt == 0 {
stepID := 0
@@ -166,7 +161,7 @@ func seedFlowsAndStations(ctx context.Context, s *Service) {
SetCollectType("AUTO").SetIsTorque(true).Save(ctx)
}
}
// 工位 N 绑定工 N 的默认流程
// 工位 N 绑定工 N 的默认流程
st, err := s.ctx.EntClient.Station.Query().Where(station.StationNo(i)).First(ctx)
if err != nil {
_, _ = s.ctx.EntClient.Station.Create().