fix(erp): 修复采购计划到货统计准确性问题

- 直接从到货明细重新计算到货/在途统计数据,避免数据库缓存导致的数据不准确
- 更新在途状态判断逻辑,在途等于所有已上传但尚未到货的卷,不论WMS中是否有记录
- 移除未到货状态,未到货的全部计入在途状态
- 立即加载详情而不等待WMS刷新,提升用户体验
- 在WMS钢卷导出功能中添加钢卷ID字段支持
This commit is contained in:
2026-07-04 14:19:25 +08:00
parent d42c4c5a94
commit ec40ab90ba
5 changed files with 36 additions and 8 deletions

View File

@@ -94,6 +94,28 @@ public class ErpPurchasePlanServiceImpl implements IErpPurchasePlanService {
if (vo.getContractCodes() != null && !vo.getContractCodes().isEmpty()) { if (vo.getContractCodes() != null && !vo.getContractCodes().isEmpty()) {
vo.setContractInfos(baseMapper.selectContractsByOrderCodes(vo.getContractCodes())); vo.setContractInfos(baseMapper.selectContractsByOrderCodes(vo.getContractCodes()));
} }
// 直接从到货明细重新计算到货/在途统计,避免 DB 缓存导致数据不准
List<ErpPurchasePlanDelivery> deliveries = deliveryMapper.selectList(
Wrappers.lambdaQuery(ErpPurchasePlanDelivery.class)
.eq(ErpPurchasePlanDelivery::getPlanId, planId));
int arrivedCount = 0;
int transitCount = 0;
BigDecimal arrivedWeight = BigDecimal.ZERO;
BigDecimal transitWeight = BigDecimal.ZERO;
for (ErpPurchasePlanDelivery d : deliveries) {
BigDecimal w = d.getCoilWeight() == null ? BigDecimal.ZERO : d.getCoilWeight();
if (d.getArrived() != null && d.getArrived() == 1) {
arrivedCount++;
arrivedWeight = arrivedWeight.add(w);
} else {
transitCount++;
transitWeight = transitWeight.add(w);
}
}
vo.setArrivedCount(arrivedCount);
vo.setArrivedWeight(arrivedWeight);
vo.setInTransitCount(transitCount);
vo.setInTransitWeight(transitWeight);
fillProgress(vo); fillProgress(vo);
// 审核历史(含每次驳回理由) // 审核历史(含每次驳回理由)
vo.setAuditLogs(queryAuditLogs(planId)); vo.setAuditLogs(queryAuditLogs(planId));
@@ -372,7 +394,8 @@ public class ErpPurchasePlanServiceImpl implements IErpPurchasePlanService {
} }
String coil = normCoil(row.getCoilNo()); String coil = normCoil(row.getCoilNo());
boolean arrived = !coil.isEmpty() && arrivedSet.contains(coil); boolean arrived = !coil.isEmpty() && arrivedSet.contains(coil);
boolean transit = !arrived && !coil.isEmpty() && inTransitSet.contains(coil); // 在途 = 所有已上传但尚未到货的卷(不论 WMS 中是否有记录)
boolean transit = !arrived && !coil.isEmpty();
ErpPurchasePlanDelivery d = new ErpPurchasePlanDelivery(); ErpPurchasePlanDelivery d = new ErpPurchasePlanDelivery();
d.setPlanId(planId); d.setPlanId(planId);
d.setArrived(arrived ? 1 : 0); d.setArrived(arrived ? 1 : 0);
@@ -537,7 +560,8 @@ public class ErpPurchasePlanServiceImpl implements IErpPurchasePlanService {
for (ErpPurchasePlanDelivery d : deliveries) { for (ErpPurchasePlanDelivery d : deliveries) {
String coil = normCoil(d.getCoilNo()); String coil = normCoil(d.getCoilNo());
int nowArrived = !coil.isEmpty() && arrivedSet.contains(coil) ? 1 : 0; int nowArrived = !coil.isEmpty() && arrivedSet.contains(coil) ? 1 : 0;
int nowTransit = nowArrived == 0 && !coil.isEmpty() && inTransitSet.contains(coil) ? 1 : 0; // 在途 = 所有已上传但尚未到货的卷(不论 WMS 中是否有记录)
int nowTransit = nowArrived == 0 && !coil.isEmpty() ? 1 : 0;
if (d.getArrived() == null || d.getArrived() != nowArrived if (d.getArrived() == null || d.getArrived() != nowArrived
|| d.getInTransit() == null || d.getInTransit() != nowTransit) { || d.getInTransit() == null || d.getInTransit() != nowTransit) {
d.setArrived(nowArrived); d.setArrived(nowArrived);
@@ -548,7 +572,8 @@ public class ErpPurchasePlanServiceImpl implements IErpPurchasePlanService {
if (nowArrived == 1) { if (nowArrived == 1) {
arrivedCount++; arrivedCount++;
arrivedWeight = arrivedWeight.add(w); arrivedWeight = arrivedWeight.add(w);
} else if (nowTransit == 1) { } else {
// 未到货的全部计入在途
transitCount++; transitCount++;
transitWeight = transitWeight.add(w); transitWeight = transitWeight.add(w);
} }

View File

@@ -209,7 +209,9 @@ export default {
this.activeTab = 'all' this.activeTab = 'all'
this.current = { ...p } this.current = { ...p }
this.deliveryList = [] this.deliveryList = []
// 打开即静默按钢卷表复核一次到货状态 // 立即加载详情,不等待 WMS 刷新
this.refreshDetail()
// 后台静默按钢卷表复核一次到货状态
const planId = p.planId const planId = p.planId
refreshArrival(planId).catch(() => {}).finally(() => { refreshArrival(planId).catch(() => {}).finally(() => {
if (this.current.planId === planId) this.refreshDetail() if (this.current.planId === planId) this.refreshDetail()
@@ -238,13 +240,11 @@ export default {
}, },
statusText(row) { statusText(row) {
if (row.arrived === 1) return '已到货' if (row.arrived === 1) return '已到货'
if (row.inTransit === 1) return '在途' return '在途'
return '未到'
}, },
statusClass(row) { statusClass(row) {
if (row.arrived === 1) return 'yes' if (row.arrived === 1) return 'yes'
if (row.inTransit === 1) return 'transit' return 'transit'
return 'no'
}, },
handleUploadSuccess(res) { handleUploadSuccess(res) {
if (res.code === 200) { if (res.code === 200) {

View File

@@ -212,6 +212,7 @@ public class WmsMaterialCoilController extends BaseController {
columns.put("rawMaterialThickness", "原料厚度"); columns.put("rawMaterialThickness", "原料厚度");
columns.put("chromePlateCoilNo", "工序卷号"); columns.put("chromePlateCoilNo", "工序卷号");
columns.put("thicknessDifference", "厚度差"); columns.put("thicknessDifference", "厚度差");
columns.put("coilId", "钢卷ID");
return R.ok(columns); return R.ok(columns);
} }

View File

@@ -190,6 +190,7 @@ public class WmsMaterialCoilExportVo {
/** /**
* 钢卷ID 此处不展示在报表只是方便set值 * 钢卷ID 此处不展示在报表只是方便set值
*/ */
@ExcelProperty(value = "钢卷ID")
private Long coilId; private Long coilId;
/** /**

View File

@@ -322,6 +322,7 @@ public class WmsCoilWarehouseOperationLogServiceImpl implements IWmsCoilWarehous
exportVo.setManufacturer(coil.getManufacturer()); exportVo.setManufacturer(coil.getManufacturer());
exportVo.setSurfaceTreatmentDesc(coil.getSurfaceTreatmentDesc()); exportVo.setSurfaceTreatmentDesc(coil.getSurfaceTreatmentDesc());
exportVo.setZincLayer(coil.getZincLayer()); exportVo.setZincLayer(coil.getZincLayer());
exportVo.setCoilId(coil.getCoilId());
exportVo.setCreateTime(coil.getCreateTime()); exportVo.setCreateTime(coil.getCreateTime());
exportVo.setLogicalWarehouseName(coil.getWarehouseName()); exportVo.setLogicalWarehouseName(coil.getWarehouseName());
exportVo.setActualWarehouseName(coil.getActualWarehouseName()); exportVo.setActualWarehouseName(coil.getActualWarehouseName());