feat:多项功能优化
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/inspectionrecord"
|
||||
"bj_power_mes/ent/materialqtyreport"
|
||||
"bj_power_mes/ent/workorder"
|
||||
)
|
||||
|
||||
@@ -51,8 +50,8 @@ type QtyReportReq struct {
|
||||
StationNo int `json:"stationNo"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
Sn string `json:"sn"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
PlanQty int `json:"planQty"`
|
||||
ActualQty int `json:"actualQty"`
|
||||
Cause string `json:"cause"`
|
||||
@@ -60,6 +59,8 @@ type QtyReportReq struct {
|
||||
}
|
||||
|
||||
// CreateQtyReport 数量不符上报:落 material_qty_report + 预警中心消息(type=qty_diff)。
|
||||
// MES 侧仅预警,不承载明细处理流程:相关内容融合为一段文字描述写入预警内容,
|
||||
// 由预警中心与右上角铃铛统一呈现;明细与闭环由 WMS 负责。
|
||||
func (s *Service) CreateQtyReport(ctx context.Context, req QtyReportReq) error {
|
||||
if req.StationNo <= 0 || req.MaterialCode == "" {
|
||||
return errors.New("工位号与物料编码必填")
|
||||
@@ -81,12 +82,27 @@ func (s *Service) CreateQtyReport(ctx context.Context, req QtyReportReq) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content := fmt.Sprintf("工位 %d 数量不符:物料 %s 应发 %d / 实收 %d / 差异 %d。原因:%s",
|
||||
req.StationNo, req.MaterialCode, req.PlanQty, req.ActualQty, diff, req.Cause)
|
||||
// 融合成单段文字描述,直接写入预警「内容」(即预警原因)。
|
||||
cause := req.Cause
|
||||
if cause == "" {
|
||||
cause = "未填写"
|
||||
}
|
||||
content := fmt.Sprintf("工位%d 数量不符:物料 %s", req.StationNo, req.MaterialCode)
|
||||
if req.MaterialName != "" {
|
||||
content += "(" + req.MaterialName + ")"
|
||||
}
|
||||
content += fmt.Sprintf(";应发 %d,实收 %d,差异 %d", req.PlanQty, req.ActualQty, diff)
|
||||
if req.OrderNo != "" {
|
||||
content += ";工单 " + req.OrderNo
|
||||
}
|
||||
if req.Sn != "" {
|
||||
content += ";序列号 " + req.Sn
|
||||
}
|
||||
content += ";上报原因:" + cause
|
||||
_, _ = s.ctx.EntClient.Alert.Create().
|
||||
SetRuleId(0).
|
||||
SetType("qty_diff").
|
||||
SetTitle("数量不符上报").
|
||||
SetTitle("数量不符预警").
|
||||
SetContent(content).
|
||||
SetRefType("material_qty_report").
|
||||
SetRefId(req.MaterialCode).
|
||||
@@ -99,21 +115,6 @@ func (s *Service) CreateQtyReport(ctx context.Context, req QtyReportReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListQtyReports 数量不符上报列表
|
||||
func (s *Service) ListQtyReports(ctx context.Context, status, orderNo, materialCode string) ([]*ent.MaterialQtyReport, error) {
|
||||
q := s.ctx.EntClient.MaterialQtyReport.Query()
|
||||
if status != "" {
|
||||
q = q.Where(materialqtyreport.Status(status))
|
||||
}
|
||||
if orderNo != "" {
|
||||
q = q.Where(materialqtyreport.OrderNoContainsFold(orderNo))
|
||||
}
|
||||
if materialCode != "" {
|
||||
q = q.Where(materialqtyreport.MaterialCodeContainsFold(materialCode))
|
||||
}
|
||||
return q.Order(ent.Desc(materialqtyreport.FieldCreatedAt), ent.Desc(materialqtyreport.FieldID)).All(ctx)
|
||||
}
|
||||
|
||||
// StationReturnMaterial 工位退料回库房:落事件日志 + 调 WMS 预建待确认退库单。
|
||||
// 退库单在 WMS 侧由库管确认收货后库存加回(链路封闭,问题记录 L491)。
|
||||
func (s *Service) StationReturnMaterial(ctx context.Context, orderNo string, stationNo int, sn, materialCode, materialName, spec, reason, operator, unit string, qty int) error {
|
||||
|
||||
Reference in New Issue
Block a user