feat&refactor: 完成多模块功能迭代与配置优化
本次提交覆盖多个业务模块的功能完善与体验优化:
1. **鉴权与配置调整**:
- 统一JWT滑动续签逻辑,简化Token存储,移除RefreshToken相关冗余代码
- 调整多项目配置文件中JWT过期时间为3600秒,统一会话闲置窗口
- 工位配置放开1~12限制,改为仅校验大于0
2. **术语统一替换**:全链路将"精密件"替换为"电气件",修正物料管理描述
3. **功能新增**:
- 新增工位类型、工艺路线与产线点位台账模块
- 添加工艺PDF预览面板、工位终端代理转发接口
- 新增操作日志按操作人列表筛选、工位登出日志记录
- 新增PLC移料指令与产线点位状态管理
4. **业务流程优化**:
- 调整BOM物料删除校验逻辑,优化工单备料计算
- 补充物料图号、检测单号等追溯字段
- 完善工艺流程图与工位绑定关系说明
- 优化前端页面文案与交互细节
5. **代码规范与维护**:
- 新增通用工具函数与前端静态资源
- 整理路由权限与中间件逻辑
- 修复部分接口与配置的不兼容问题
This commit is contained in:
@@ -68,7 +68,7 @@ func (s *Service) BindWorkpiece(ctx context.Context, sn, orderNo string, process
|
||||
// BindItemReq 单条装机绑定请求(报工时随 steps 一并提交)
|
||||
type BindItemReq struct {
|
||||
MaterialCode string `json:"materialCode"`
|
||||
BindValue string `json:"bindValue"` // 结构件=批次号;精密件=SN
|
||||
BindValue string `json:"bindValue"` // 结构件=批次号;电气件=SN
|
||||
}
|
||||
|
||||
// bindTarget 由 BOM 解析出的某工序应装物料定义
|
||||
@@ -77,7 +77,7 @@ type bindTarget struct {
|
||||
MaterialName string
|
||||
Spec string
|
||||
Unit string
|
||||
ManageMode string // 1 批次(结构件) / 2 SN(精密件)
|
||||
ManageMode string // 1 批次(结构件) / 2 SN(电气件)
|
||||
UnitQty float64
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (s *Service) stationBindTargets(ctx context.Context, productCode, bomName s
|
||||
|
||||
// applyBinds 报工时应用装机绑定(落库 + 防错校验):
|
||||
// ① 料必须属于该产品 BOM 且装配工序配置为本工序(processCode==当前工序);
|
||||
// ② 精密件 SN 全局防重:已被其他工件绑定则拒绝(防错拿/防重复装机);
|
||||
// ② 电气件 SN 全局防重:已被其他工件绑定则拒绝(防错拿/防重复装机);
|
||||
// ③ 同一工件同一料同一绑定值幂等(重复扫码不报错,静默去重)。
|
||||
// 返回绑定成功条数。
|
||||
func (s *Service) applyBinds(ctx context.Context, sn, orderNo string, processCode int, stationNo string, operator string, items []BindItemReq) (int, error) {
|
||||
@@ -135,7 +135,7 @@ func (s *Service) applyBinds(ctx context.Context, sn, orderNo string, processCod
|
||||
// 工单锁定 BOM 的全量索引:materialCode → target(校验料合法性 + 取物料快照)
|
||||
bomMap := map[string]*ent.BomItem{}
|
||||
allBom, _ := s.ctx.EntClient.BomItem.Query().
|
||||
Where(bomitem.ProductCode(productCode), bomitem.BomName(bomNameOrDefault(wo.BomName))).All(ctx)
|
||||
Where(bomitem.ProductCode(productCode), bomitem.BomName(bomNameOrDefault(""))).All(ctx)
|
||||
for _, b := range allBom {
|
||||
bomMap[b.MaterialCode] = b
|
||||
}
|
||||
@@ -159,12 +159,12 @@ func (s *Service) applyBinds(ctx context.Context, sn, orderNo string, processCod
|
||||
if exists {
|
||||
continue
|
||||
}
|
||||
// 精密件 SN 全局防重
|
||||
// 电气件 SN 全局防重
|
||||
if bi.ManageMode == "2" {
|
||||
other, _ := s.ctx.EntClient.WorkpieceBind.Query().
|
||||
Where(workpiecebind.BindValue(bv), workpiecebind.BindType("SN"), workpiecebind.SnNEQ(sn)).First(ctx)
|
||||
if other != nil {
|
||||
return bound, fmt.Errorf("精密件SN %s 已绑定到工件 %s(工序%d),不能重复装机", bv, other.Sn, other.ProcessCode)
|
||||
return bound, fmt.Errorf("电气件SN %s 已绑定到工件 %s(工序%d),不能重复装机", bv, other.Sn, other.ProcessCode)
|
||||
}
|
||||
}
|
||||
bindType := "BATCH"
|
||||
@@ -185,14 +185,14 @@ func (s *Service) applyBinds(ctx context.Context, sn, orderNo string, processCod
|
||||
}
|
||||
|
||||
// validateStationBinds 校验某工件在某工序的装配物料是否绑齐(工艺流程强校验核心):
|
||||
// 返回缺料明细(空串=齐套)。判定:精密件(SN) 绑定的不同SN数 ≥ 单台用量;结构件(批次) 至少绑定1个批次号。
|
||||
// 返回缺料明细(空串=齐套)。判定:电气件(SN) 绑定的不同SN数 ≥ 单台用量;结构件(批次) 至少绑定1个批次号。
|
||||
// 若该产品该工序未配置任何装配物料(processCode未配置),视为不启用绑定校验,放行。
|
||||
func (s *Service) validateStationBinds(ctx context.Context, sn string, processCode int) (string, error) {
|
||||
_, wo, err := s.workpieceProduct(ctx, sn)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
targets, err := s.stationBindTargets(ctx, wo.ProductCode, wo.BomName, processCode)
|
||||
targets, err := s.stationBindTargets(ctx, wo.ProductCode, "", processCode)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func (s *Service) validateStationBinds(ctx context.Context, sn string, processCo
|
||||
if need < 1 {
|
||||
need = 1
|
||||
}
|
||||
if t.ManageMode == "2" { // 精密件 SN:需绑满单台用量
|
||||
if t.ManageMode == "2" { // 电气件 SN:需绑满单台用量
|
||||
if boundCount < need {
|
||||
missing = append(missing, fmt.Sprintf("%s(%s):需绑定%d颗SN,已绑%d颗", t.MaterialCode, t.MaterialName, need, boundCount))
|
||||
}
|
||||
@@ -316,7 +316,7 @@ func (s *Service) StationBindPanelData(ctx context.Context, sn string, processCo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
targets, err := s.stationBindTargets(ctx, wo.ProductCode, wo.BomName, processCode)
|
||||
targets, err := s.stationBindTargets(ctx, wo.ProductCode, "", processCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user