feat(material): 添加材料卷导出功能的时间字段兜底处理

- 在 WmsMaterialCoilExportVo 中新增 updateTime 字段用于时间兜底
- 在数据库查询映射中添加 update_time 字段的查询支持
- 实现发货时间为空时的时间字段处理逻辑,按优先级选择时间
- 优化导出列表的时间字段赋值策略,确保日期字段不为空
This commit is contained in:
2026-01-12 10:01:59 +08:00
parent 4f3b662b72
commit db95dd3a67
3 changed files with 23 additions and 3 deletions

View File

@@ -161,4 +161,9 @@ public class WmsMaterialCoilExportVo {
* 发货时间(仅临时存储,不导出) * 发货时间(仅临时存储,不导出)
*/ */
private Date exportTime; private Date exportTime;
/**
* 更新时间(仅临时存储,不导出,用于发货时间为空时兜底)
*/
private Date updateTime;
} }

View File

@@ -1862,12 +1862,25 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
public List<WmsMaterialCoilExportVo> queryExportList(WmsMaterialCoilBo bo) { public List<WmsMaterialCoilExportVo> queryExportList(WmsMaterialCoilBo bo) {
QueryWrapper<WmsMaterialCoil> lqw = buildQueryWrapper(bo); QueryWrapper<WmsMaterialCoil> lqw = buildQueryWrapper(bo);
List<WmsMaterialCoilExportVo> wmsMaterialCoilExportVos = baseMapper.selectExportList(lqw); List<WmsMaterialCoilExportVo> wmsMaterialCoilExportVos = baseMapper.selectExportList(lqw);
// 遍历数据,根据状态替换日期字段 // 遍历数据,根据状态替换日期字段,并处理空值兜底
wmsMaterialCoilExportVos.stream().forEach(vo -> { wmsMaterialCoilExportVos.stream().forEach(vo -> {
// 判断查询条件中的status是否为1已发货 // 判断查询条件中的status是否为1已发货
if (bo.getStatus() != null && bo.getStatus() == 1) { if (bo.getStatus() != null && bo.getStatus() == 1) {
// 已发货时将展示的日期替换为export_time Date finalDate = null;
vo.setCreateTime(vo.getExportTime()); // 1. 优先使用发货时间
if (vo.getExportTime() != null) {
finalDate = vo.getExportTime();
}
// 2. 发货时间为空时,使用更新时间兜底
else if (vo.getUpdateTime() != null) {
finalDate = vo.getUpdateTime();
}
// 3. 若更新时间也为空保留原有createTime避免日期字段为空
else {
finalDate = vo.getCreateTime();
}
// 赋值最终的日期
vo.setCreateTime(finalDate);
} }
// 非1的情况保持原有create_time不变 // 非1的情况保持原有create_time不变
}); });

View File

@@ -363,6 +363,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mc.create_time AS createTime, mc.create_time AS createTime,
-- 发货时间 -- 发货时间
mc.export_time AS exportTime, mc.export_time AS exportTime,
-- 新增:更新时间(用于发货时间为空时兜底)
mc.update_time AS updateTime,
-- 重量 -- 重量
mc.net_weight AS netWeight, mc.net_weight AS netWeight,
-- 长度 -- 长度