feat: 补充宏观排产结果展示字段

parent 24eee50e
......@@ -689,7 +689,7 @@ public class MacroPlannerDataConverter {
// 3.1 为每个 Material 创建 Product
for (Material m : ctx.materialByMaterialId.values()) {
String name = pickName(m.getName(), m.getCode(), m.getId());
Product p = new Product(m.getCode(), name);
Product p = new Product(m.getCode(), name, m.getCode());
products.add(p);
ctx.productByMaterialId.put(m.getId(), p);
}
......@@ -1269,7 +1269,8 @@ public class MacroPlannerDataConverter {
orderEnd = deliveryDate.plusDays(1); // +1 使结束时间包含当天
} else {
// 无时间信息, 放入最后一个周期
salesDemands.add(new SalesDemand(p, sp, lastPeriod, qty, priority, ado.getId()));
salesDemands.add(new SalesDemand(p, sp, lastPeriod, qty, priority,
ado.getId(), ado.getCode(), pickName(ado.getMmcode(), p.getId())));
continue;
}
......@@ -1290,7 +1291,8 @@ public class MacroPlannerDataConverter {
}
if (overlapPeriods.isEmpty()) {
salesDemands.add(new SalesDemand(p, sp, lastPeriod, qty, priority, ado.getId()));
salesDemands.add(new SalesDemand(p, sp, lastPeriod, qty, priority,
ado.getId(), ado.getCode(), pickName(ado.getMmcode(), p.getId())));
} else {
// 按重叠天数比例拆分需求量: 每期四舍五入取整, 最后一期补差保证总和等于总数
int totalQty = (int) Math.round(qty);
......@@ -1306,7 +1308,8 @@ public class MacroPlannerDataConverter {
periodQty = (int) Math.round(qty * overlapDays / (double) totalRangeDays);
allocated += periodQty;
}
salesDemands.add(new SalesDemand(p, sp, per, periodQty, priority, ado.getId()));
salesDemands.add(new SalesDemand(p, sp, per, periodQty, priority,
ado.getId(), ado.getCode(), pickName(ado.getMmcode(), p.getId())));
}
}
}
......
......@@ -6,14 +6,21 @@ package com.aps.macroplanner.data;
public class Product {
private final String id;
private final String name;
private final String code;
public Product(String id, String name) {
this(id, name, id);
}
public Product(String id, String name, String code) {
this.id = id;
this.name = name;
this.code = code;
}
public String getId() { return id; }
public String getName() { return name; }
public String getCode() { return code; }
@Override
public String toString() {
......
......@@ -11,6 +11,8 @@ public class SalesDemand {
private final double quantity; // 需求总量
private final double priority; // 需求优先级
private final String demandOrderId; // 来源订单ID (ApsDemandOrder.id), 可空
private final String orderCode;
private final String productCode;
public SalesDemand(Product product, StockingPoint stockingPoint, Period period,
double quantity, double priority) {
......@@ -19,12 +21,20 @@ public class SalesDemand {
public SalesDemand(Product product, StockingPoint stockingPoint, Period period,
double quantity, double priority, String demandOrderId) {
this(product, stockingPoint, period, quantity, priority, demandOrderId, null, null);
}
public SalesDemand(Product product, StockingPoint stockingPoint, Period period,
double quantity, double priority, String demandOrderId,
String orderCode, String productCode) {
this.product = product;
this.stockingPoint = stockingPoint;
this.period = period;
this.quantity = quantity;
this.priority = priority;
this.demandOrderId = demandOrderId;
this.orderCode = orderCode;
this.productCode = productCode;
}
public Product getProduct() { return product; }
......@@ -33,6 +43,8 @@ public class SalesDemand {
public double getQuantity() { return quantity; }
public double getPriority() { return priority; }
public String getDemandOrderId() { return demandOrderId; }
public String getOrderCode() { return orderCode; }
public String getProductCode() { return productCode; }
public String getKey() {
return product.getId() + "_" + stockingPoint.getId() + "_" + period.getIndex();
......
......@@ -410,7 +410,9 @@ public class ResultWriter {
for (SalesDemand sd : data.getSalesDemands()) {
SalesDemandResult sr = new SalesDemandResult();
sr.setSalesDemandId(sd.getDemandOrderId()==null? sd.getKey():sd.getDemandOrderId());
sr.setOrderCode(sd.getOrderCode());
sr.setProductId(sd.getProduct().getId());
sr.setProductCode(sd.getProductCode());
sr.setSpId(sd.getStockingPoint().getId());
sr.setPeriodIndex(sd.getPeriod().getIndex());
sr.setPeriodStartDate(sd.getPeriod().getStartDate().toString());
......@@ -473,7 +475,8 @@ public class ResultWriter {
}
double available = openingInv + totalArrived;
if (available < demandQty) {
reasons.add("库存耗尽(可用" + fmt(available) + "件, 需求" + fmt(demandQty) + "件)");
addReasonWithDetail(reasons, "库存耗尽",
"(可用" + fmt(available) + "件, 需求" + fmt(demandQty) + "件)");
}
// 2. 产能瓶颈: 所有生产该产品的单元满负荷 (利用率 > 95%)
......@@ -552,6 +555,11 @@ public class ResultWriter {
}
}
private void addReasonWithDetail(java.util.List<String> reasons, String title, String detail) {
reasons.add(title);
reasons.add(detail);
}
/**
* 分析销售需求的风险 (即使本期已满足)。
*
......@@ -702,6 +710,7 @@ public class ResultWriter {
for (Period p : data.getPeriods()) {
PispipResult pr = new PispipResult();
pr.setProductId(prod.getId());
pr.setProductCode(prod.getCode());
pr.setSpId(sp.getId());
pr.setPeriodIndex(p.getIndex());
pr.setPeriodStartDate(p.getStartDate().toString());
......@@ -1221,7 +1230,9 @@ public class ResultWriter {
for (SalesDemandResult sr : result.getSalesDemands()) {
jb.obj();
jb.key("salesDemandId").val(sr.getSalesDemandId());
jb.key("orderCode").val(sr.getOrderCode());
jb.key("productId").val(sr.getProductId());
jb.key("productCode").val(sr.getProductCode());
jb.key("spId").val(sr.getSpId());
jb.key("periodIndex").val(sr.getPeriodIndex());
jb.key("periodStartDate").val(sr.getPeriodStartDate());
......@@ -1251,6 +1262,7 @@ public class ResultWriter {
for (PispipResult pr : result.getPispips()) {
jb.obj();
jb.key("productId").val(pr.getProductId());
jb.key("productCode").val(pr.getProductCode());
jb.key("spId").val(pr.getSpId());
jb.key("periodIndex").val(pr.getPeriodIndex());
jb.key("periodStartDate").val(pr.getPeriodStartDate());
......
......@@ -11,6 +11,7 @@ import java.util.List;
public class PispipResult {
private String productId;
private String productCode;
private String spId;
private int periodIndex;
private String periodStartDate;
......@@ -103,6 +104,9 @@ public class PispipResult {
public String getProductId() { return productId; }
public void setProductId(String v) { this.productId = v; }
public String getProductCode() { return productCode; }
public void setProductCode(String v) { this.productCode = v; }
public String getSpId() { return spId; }
public void setSpId(String v) { this.spId = v; }
......
......@@ -11,7 +11,9 @@ import java.util.List;
public class SalesDemandResult {
private String salesDemandId;
private String orderCode;
private String productId;
private String productCode;
private String spId;
private int periodIndex;
private String periodStartDate;
......@@ -39,9 +41,15 @@ public class SalesDemandResult {
public String getSalesDemandId() { return salesDemandId; }
public void setSalesDemandId(String v) { this.salesDemandId = v; }
public String getOrderCode() { return orderCode; }
public void setOrderCode(String v) { this.orderCode = v; }
public String getProductId() { return productId; }
public void setProductId(String v) { this.productId = v; }
public String getProductCode() { return productCode; }
public void setProductCode(String v) { this.productCode = v; }
public String getSpId() { return spId; }
public void setSpId(String v) { this.spId = v; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment