上架增加库存默认修改时间

This commit is contained in:
秦鸿展
2026-04-02 17:57:02 +08:00
parent 92d252cbe0
commit 7c314a796f
2 changed files with 20 additions and 0 deletions
@@ -728,6 +728,11 @@ public class StockShelfOrderDomainService {
materialInventory.setCreateByName(loginUser.getUsername()); materialInventory.setCreateByName(loginUser.getUsername());
materialInventory.setCreateTime(new Date()); materialInventory.setCreateTime(new Date());
// 新增库存时同步更新时间(update_time
materialInventory.setUpdateBy(loginUser.getUserid());
materialInventory.setUpdateByName(loginUser.getUsername());
materialInventory.setUpdateTime(new Date());
//体积 重量等 //体积 重量等
materialInventory.setVolume(shelfMaterialDetail.getTotalVolume()); materialInventory.setVolume(shelfMaterialDetail.getTotalVolume());
materialInventory.setArea(shelfMaterialDetail.getTotalArea()); materialInventory.setArea(shelfMaterialDetail.getTotalArea());
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@@ -79,6 +80,15 @@ public class MaterialInventoryApi extends BaseController {
startPage(); startPage();
// 使用带批次属性的查询方法,批次属性值从库存表中获取 // 使用带批次属性的查询方法,批次属性值从库存表中获取
List<MaterialInventoryPO> list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO); List<MaterialInventoryPO> list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO);
// 按更新时间倒序排序;update_time 为空的数据放最后
list.sort((o1, o2) -> {
Date t1 = o1.getUpdateTime();
Date t2 = o2.getUpdateTime();
if (t1 == null && t2 == null) return 0;
if (t1 == null) return 1;
if (t2 == null) return -1;
return t2.compareTo(t1); // desc
});
TableDataInfo tableDataInfo = getDataTable(list); TableDataInfo tableDataInfo = getDataTable(list);
// 如果查询结果为空,抛出异常提示用户该物料在库存中不存在 // 如果查询结果为空,抛出异常提示用户该物料在库存中不存在
// if (tableDataInfo.getTotal() == 0) { // if (tableDataInfo.getTotal() == 0) {
@@ -136,6 +146,11 @@ public class MaterialInventoryApi extends BaseController {
if(materialInventoryDTO.getMaterialInventoryId() != null){ if(materialInventoryDTO.getMaterialInventoryId() != null){
return toAjax(materialInventoryApplicationService.update(materialInventoryDO)); return toAjax(materialInventoryApplicationService.update(materialInventoryDO));
}else { }else {
// 新增时补齐更新时间(update_time),避免新增数据 update_time 为空
materialInventoryDO.setUpdateTime(new Date());
// update_by/update_by_name 与 create_by/create_by_name 保持一致
materialInventoryDO.setUpdateBy(materialInventoryDO.getCreateBy());
materialInventoryDO.setUpdateByName(materialInventoryDO.getCreateByName());
return toAjax(materialInventoryApplicationService.insert(materialInventoryDO)); return toAjax(materialInventoryApplicationService.insert(materialInventoryDO));
} }
} }