feat(material): 添加材料卷导出功能的时间字段兜底处理
- 在 WmsMaterialCoilExportVo 中新增 updateTime 字段用于时间兜底 - 在数据库查询映射中添加 update_time 字段的查询支持 - 实现发货时间为空时的时间字段处理逻辑,按优先级选择时间 - 优化导出列表的时间字段赋值策略,确保日期字段不为空
This commit is contained in:
@@ -161,4 +161,9 @@ public class WmsMaterialCoilExportVo {
|
||||
* 发货时间(仅临时存储,不导出)
|
||||
*/
|
||||
private Date exportTime;
|
||||
|
||||
/**
|
||||
* 更新时间(仅临时存储,不导出,用于发货时间为空时兜底)
|
||||
*/
|
||||
private Date updateTime;
|
||||
}
|
||||
|
||||
@@ -1862,12 +1862,25 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
public List<WmsMaterialCoilExportVo> queryExportList(WmsMaterialCoilBo bo) {
|
||||
QueryWrapper<WmsMaterialCoil> lqw = buildQueryWrapper(bo);
|
||||
List<WmsMaterialCoilExportVo> wmsMaterialCoilExportVos = baseMapper.selectExportList(lqw);
|
||||
// 遍历数据,根据状态替换日期字段
|
||||
// 遍历数据,根据状态替换日期字段,并处理空值兜底
|
||||
wmsMaterialCoilExportVos.stream().forEach(vo -> {
|
||||
// 判断查询条件中的status是否为1(已发货)
|
||||
if (bo.getStatus() != null && bo.getStatus() == 1) {
|
||||
// 已发货时,将展示的日期替换为export_time
|
||||
vo.setCreateTime(vo.getExportTime());
|
||||
Date finalDate = null;
|
||||
// 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不变
|
||||
});
|
||||
|
||||
@@ -363,6 +363,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
mc.create_time AS createTime,
|
||||
-- 发货时间
|
||||
mc.export_time AS exportTime,
|
||||
-- 新增:更新时间(用于发货时间为空时兜底)
|
||||
mc.update_time AS updateTime,
|
||||
-- 重量
|
||||
mc.net_weight AS netWeight,
|
||||
-- 长度
|
||||
|
||||
Reference in New Issue
Block a user