feat: 移除工艺物料与混产模板实体、新增产线清线与 PLC 监控实时推送、看板双屏增强
- 移除实体:MES 删除 FlowMaterial(工艺物料)与 MixProductionTemplate(混产模板)全套(schema/ent 生成码/handler/logic),清理关联路由与种子 - 新增功能:产线清线(line_clearance handler + logic)、PLC 监控 WebSocket 实时推送(ws/plc_monitor_hub + handler) - 看板增强:新增管理屏与 KPI 组件(BoardManage/BoardKpi),调整演示屏 Mock 与各看板面板 - MES 完善:PLC 匹配/扭矩扫描/签收、工艺卡 PDF 与工单、AGV 链路、叫料/备料/在制品/短料预测等逻辑与前端调整 - 工位终端:删除离线面板 OfflinePanel,调整主界面/物料面板与 api/store/handler/路由 - WMS:AGV 托盘、物料与 MES 客户端调整及前端帮助/基础数据/叫料/托盘页 - 文档:更新产线API/客户问题/案例/部署手册/问题记录
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/dailyplan"
|
||||
"bj_power_mes/ent/flowmaterial"
|
||||
"bj_power_mes/ent/productbom"
|
||||
"bj_power_mes/ent/productprocessmaterial"
|
||||
"bj_power_mes/ent/workorder"
|
||||
"bj_power_mes/internal/wmsclient"
|
||||
@@ -53,7 +53,7 @@ type ProducibleDailyRow struct {
|
||||
Consumed float64 `json:"consumed"` // 当日消耗(当日该物料需求台数 × 单台含损耗用量)
|
||||
Before float64 `json:"before"` // 当日扣减前可用量
|
||||
Remain float64 `json:"remain"` // 当日扣减后剩余量
|
||||
Source string `json:"source"` // 账目来源:产品工艺分账 / 工序总账(无分账回退)
|
||||
Source string `json:"source"` // 账目来源:产品工艺分账 / 工艺总账(无分账回退)
|
||||
}
|
||||
|
||||
// ProducibleOrderRow 单工单逐日模拟结果(按工单逐个模拟消耗)
|
||||
@@ -68,19 +68,19 @@ type ProducibleOrderRow struct {
|
||||
UsageBreakdown []ProducibleUsageRow `json:"usageBreakdown"`
|
||||
}
|
||||
|
||||
// ProducibleUsageRow 抽屉里的「物料账目来源」明细:按产品工艺分账逐工序列出的单台用量。
|
||||
// 宏观测算与逐日消耗仍走工序总账口径,本结构只用于展示账目来源,不参与计算。
|
||||
// ProducibleUsageRow 抽屉里的「物料账目来源」明细:按产品工艺分账逐工艺列出的单台用量。
|
||||
// 宏观测算与逐日消耗仍走工艺总账口径,本结构只用于展示账目来源,不参与计算。
|
||||
type ProducibleUsageRow struct {
|
||||
Seq int `json:"seq"` // 工单工艺组合中的第几道工序
|
||||
Seq int `json:"seq"` // 工单工艺组合中的第几道工艺
|
||||
FlowId int `json:"flowId"`
|
||||
FlowName string `json:"flowName"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
Unit string `json:"unit"`
|
||||
UnitQty float64 `json:"unitQty"` // 单台净用量
|
||||
LossRate float64 `json:"lossRate"` // 损耗率%(展示口径,取工序总账)
|
||||
LossRate float64 `json:"lossRate"` // 损耗率%(展示口径,取工艺总账)
|
||||
EffQty float64 `json:"effQty"` // 单台含损耗用量
|
||||
Source string `json:"source"` // 产品工艺分账 / 工序总账(无分账回退)
|
||||
Source string `json:"source"` // 产品工艺分账 / 工艺总账(无分账回退)
|
||||
}
|
||||
|
||||
// ProducibleBottleneck 总支撑瓶颈:最早见底那个工单
|
||||
@@ -382,8 +382,8 @@ func (s *Service) ComputeProducibleSupport(ctx context.Context) (*ProducibleSupp
|
||||
}
|
||||
res.Orders, res.Bottleneck = s.simulateSupportByOrder(ctx, usageByOrder, base.Avail, qtyByOrder, codeByOrder)
|
||||
|
||||
// 逐工单补「物料账目来源」明细:宏观汇总与逐日消耗口径不变(工序总账),
|
||||
// 明细区另按产品工艺分账逐工序展示实际领料量,点进抽屉即可核到账目来源。
|
||||
// 逐工单补「物料账目来源」明细:宏观汇总与逐日消耗口径不变(工艺总账),
|
||||
// 明细区另按产品工艺分账逐工艺展示实际领料量,点进抽屉即可核到账目来源。
|
||||
breakdownByOrder := s.loadUsageBreakdown(ctx, orderNosOf(base.Items))
|
||||
for i := range res.Orders {
|
||||
rows := breakdownByOrder[res.Orders[i].WorkOrderNo]
|
||||
@@ -397,7 +397,7 @@ func (s *Service) ComputeProducibleSupport(ctx context.Context) (*ProducibleSupp
|
||||
for j := range res.Orders[i].DailyRows {
|
||||
src := srcByCode[res.Orders[i].DailyRows[j].MaterialCode]
|
||||
if src == "" {
|
||||
src = "工序总账"
|
||||
src = "工艺总账"
|
||||
}
|
||||
res.Orders[i].DailyRows[j].Source = src
|
||||
}
|
||||
@@ -422,21 +422,19 @@ func (s *Service) loadUsageBreakdown(ctx context.Context, orderNos []string) map
|
||||
return out
|
||||
}
|
||||
|
||||
// orderUsageBreakdown 按产品工艺分账(product_process_material)逐工序列出单台用量:
|
||||
// ① 该工序在分账里有行 → 用分账行的单台净用量,损耗率取工序总账同名物料,来源标「产品工艺分账」;
|
||||
// ② 该工序无分账行 → 回退 flow_material 工序总账,来源标「工序总账(无分账回退)」;
|
||||
// ③ 工单无来源产品工艺 → 全部回退总账。
|
||||
// orderUsageBreakdown 按产品工艺分账(product_process_material)逐工艺列出单台用量(2026-11-18 纯分账口径):
|
||||
// 损耗率取产品总账(product_bom)同名物料;工艺无分账行则该工艺不列出。
|
||||
// 与 MaterialsByFlowForWO(叫料/备料/装机绑定的算料口径)同源,仅用于抽屉展示,不参与上方宏观测算。
|
||||
func (s *Service) orderUsageBreakdown(ctx context.Context, wo *ent.WorkOrder) []ProducibleUsageRow {
|
||||
if wo == nil || s.ctx.EntClient == nil {
|
||||
return []ProducibleUsageRow{}
|
||||
}
|
||||
items, _ := RouteStationsFromWO(ctx, s.ctx.EntClient, wo)
|
||||
seen := map[int]bool{}
|
||||
fseen := map[int]bool{}
|
||||
flowIDs := make([]int, 0, len(items))
|
||||
for _, it := range items {
|
||||
if it.FlowId > 0 && !seen[it.FlowId] {
|
||||
seen[it.FlowId] = true
|
||||
if it.FlowId > 0 && !fseen[it.FlowId] {
|
||||
fseen[it.FlowId] = true
|
||||
flowIDs = append(flowIDs, it.FlowId)
|
||||
}
|
||||
}
|
||||
@@ -458,36 +456,28 @@ func (s *Service) orderUsageBreakdown(ctx context.Context, wo *ent.WorkOrder) []
|
||||
}
|
||||
}
|
||||
}
|
||||
fms, _ := s.ctx.EntClient.FlowMaterial.Query().
|
||||
Where(flowmaterial.FlowIdIn(flowIDs...)).All(ctx)
|
||||
lossByCode := map[string]float64{}
|
||||
fmByFlow := map[int][]*ent.FlowMaterial{}
|
||||
for _, fm := range fms {
|
||||
lossByCode[fm.MaterialCode] = fm.LossRate
|
||||
fmByFlow[fm.FlowId] = append(fmByFlow[fm.FlowId], fm)
|
||||
if wo.ProductCode != "" {
|
||||
if boms, err := s.ctx.EntClient.ProductBOM.Query().Where(productbom.ProductCode(wo.ProductCode)).All(ctx); err == nil {
|
||||
for _, b := range boms {
|
||||
lossByCode[b.MaterialCode] = b.LossRate
|
||||
}
|
||||
}
|
||||
}
|
||||
out := make([]ProducibleUsageRow, 0, len(fms))
|
||||
out := []ProducibleUsageRow{}
|
||||
for seq, fid := range flowIDs {
|
||||
rows := allocByFlow[fid]
|
||||
if len(rows) > 0 {
|
||||
sort.SliceStable(rows, func(i, j int) bool { return rows[i].Seq < rows[j].Seq })
|
||||
for _, r := range rows {
|
||||
loss := lossByCode[r.MaterialCode]
|
||||
out = append(out, ProducibleUsageRow{
|
||||
Seq: seq + 1, FlowId: fid, FlowName: flowName[fid],
|
||||
MaterialCode: r.MaterialCode, MaterialName: r.MaterialName, Unit: r.Unit,
|
||||
UnitQty: r.UnitQty, LossRate: loss,
|
||||
EffQty: r.UnitQty * (1 + loss/100), Source: "产品工艺分账",
|
||||
})
|
||||
}
|
||||
if len(rows) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, fm := range fmByFlow[fid] {
|
||||
sort.SliceStable(rows, func(i, j int) bool { return rows[i].Seq < rows[j].Seq })
|
||||
for _, r := range rows {
|
||||
loss := lossByCode[r.MaterialCode]
|
||||
out = append(out, ProducibleUsageRow{
|
||||
Seq: seq + 1, FlowId: fid, FlowName: flowName[fid],
|
||||
MaterialCode: fm.MaterialCode, MaterialName: fm.MaterialName, Unit: fm.Unit,
|
||||
UnitQty: fm.UnitQty, LossRate: fm.LossRate,
|
||||
EffQty: fm.UnitQty * (1 + fm.LossRate/100), Source: "工序总账(无分账回退)",
|
||||
MaterialCode: r.MaterialCode, MaterialName: r.MaterialName, Unit: r.Unit,
|
||||
UnitQty: r.UnitQty, LossRate: loss,
|
||||
EffQty: r.UnitQty * (1 + loss/100), Source: "产品工艺分账",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user