refactor: 重构产线工位与备料流程,移除冗余字段
1. 移除工单、工件、日排产中的冗余工位组合/接驳台字段 2. 新增工位接驳台编码字段与唯一约束,关联WMS接驳台主数据 3. 重构日排产为工位产量分配模式,替代原接驳台列表 4. 新增备料单工位级字段与分批出库支持 5. 移除定时同步可生产数量,改为WMS实时拉取接口 6. 过滤操作日志,排除登录/退出相关日志 7. 调整仪表盘工序展示逻辑为今日派工路线 8. 新增接驳台维护菜单与基础数据
This commit is contained in:
@@ -15,21 +15,30 @@ type PlcSendReq struct {
|
||||
OrderNo string `json:"orderNo"`
|
||||
Sn string `json:"sn"`
|
||||
StationNo int `json:"stationNo"`
|
||||
ProcessCombination string `json:"processCombination"` // 如 "135"
|
||||
}
|
||||
|
||||
// SendProcess 下发 PLC 工序码。
|
||||
// 路线由「今日工位派工(station_process)」派生,不再手填组合串(全改关联表)。
|
||||
// 约束:① SN 必须属于所选工单且已进线(未完工);② 上一条工序未收到完成信号,不下发下一条(模拟 S7 握手)。
|
||||
func (s *Service) SendProcess(ctx context.Context, req PlcSendReq, operator string) (*ent.PlcSendLog, error) {
|
||||
if req.ProcessCombination == "" {
|
||||
return nil, errors.New("工位组合不能为空")
|
||||
}
|
||||
if req.OrderNo == "" {
|
||||
return nil, errors.New("请选择工单号")
|
||||
}
|
||||
if req.Sn == "" {
|
||||
return nil, errors.New("请填写/扫描工件 SN")
|
||||
}
|
||||
// 路线由今日工位派工派生
|
||||
combination, err := RouteStationsStr(ctx, s.ctx.EntClient, TodayStr(), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if combination == "" {
|
||||
return nil, errors.New("今日未配置工位派工,无法下发 PLC 工序码")
|
||||
}
|
||||
route, err := RouteStations(ctx, s.ctx.EntClient, TodayStr(), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 校验①:SN 归属工单且已进线
|
||||
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(req.OrderNo)).First(ctx)
|
||||
if err != nil {
|
||||
@@ -61,17 +70,17 @@ func (s *Service) SendProcess(ctx context.Context, req PlcSendReq, operator stri
|
||||
now := time.Now()
|
||||
rec, err := s.ctx.EntClient.PlcSendLog.Create().
|
||||
SetOrderNo(req.OrderNo).SetSn(req.Sn).SetStationNo(req.StationNo).
|
||||
SetProcessCombination(req.ProcessCombination).SetProcessCodes(ParseProcessSeq(req.ProcessCombination)).
|
||||
SetProcessCombination(combination).SetProcessCodes(route).
|
||||
SetStatus("SENT").SetSendTime(now).SetOperator(operator).Save(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 模拟下行下发
|
||||
_, err = s.ctx.PLC.Get().SendProcessCode(ctx, req.ProcessCombination)
|
||||
_, err = s.ctx.PLC.Get().SendProcessCode(ctx, combination)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.ctx.EventLog.Write(ctx, "plc.send", req.OrderNo, operator, "plc_send_log", req.Sn, "工位组合下发", map[string]any{"combination": req.ProcessCombination})
|
||||
s.ctx.EventLog.Write(ctx, "plc.send", req.OrderNo, operator, "plc_send_log", req.Sn, "工位组合下发", map[string]any{"combination": combination})
|
||||
|
||||
// mock 完成信号:延时后置为完成(演示"未完成不下发下一条"握手)
|
||||
go func(id int) {
|
||||
|
||||
Reference in New Issue
Block a user