Commit 28f62af7aa0bf7f5ed1ab43a36be83f9e06c4df5
1 parent
144963d0
feat(wms):优化 inventory history
Showing
4 changed files
with
41 additions
and
4 deletions
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/inventory/vo/detail/WmsInventoryDetailPageReqVO.java
| ... | ... | @@ -53,9 +53,8 @@ public class WmsInventoryDetailPageReqVO extends PageParam { |
| 53 | 53 | @Schema(description = "批号", example = "BATCH001") |
| 54 | 54 | private String batchNo; |
| 55 | 55 | |
| 56 | - @Schema(description = "过期日期") | |
| 57 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 58 | - private LocalDateTime[] expirationDate; | |
| 56 | + @Schema(description = "距离过期天数", example = "30") | |
| 57 | + private Integer daysToExpires; | |
| 59 | 58 | |
| 60 | 59 | @Schema(description = "创建时间") |
| 61 | 60 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/inventory/WmsInventoryDetailMapper.java
| ... | ... | @@ -10,6 +10,10 @@ import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; |
| 10 | 10 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemSkuDO; |
| 11 | 11 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 12 | |
| 13 | +import java.time.LocalDate; | |
| 14 | +import java.time.LocalDateTime; | |
| 15 | +import java.time.LocalTime; | |
| 16 | + | |
| 13 | 17 | /** |
| 14 | 18 | * WMS 库存明细 Mapper |
| 15 | 19 | * |
| ... | ... | @@ -31,12 +35,21 @@ public interface WmsInventoryDetailMapper extends BaseMapperX<WmsInventoryDetail |
| 31 | 35 | .eqIfPresent(WmsInventoryDetailDO::getWarehouseId, reqVO.getWarehouseId()) |
| 32 | 36 | .eqIfPresent(WmsInventoryDetailDO::getAreaId, reqVO.getAreaId()) |
| 33 | 37 | .likeIfPresent(WmsInventoryDetailDO::getBatchNo, reqVO.getBatchNo()) |
| 34 | - .betweenIfPresent(WmsInventoryDetailDO::getExpirationDate, reqVO.getExpirationDate()) | |
| 35 | 38 | .betweenIfPresent(WmsInventoryDetailDO::getCreateTime, reqVO.getCreateTime()); |
| 39 | + appendDaysToExpiresQuery(query, reqVO.getDaysToExpires()); | |
| 36 | 40 | appendDimensionOrder(query, reqVO.getType()); |
| 37 | 41 | return selectJoinPage(reqVO, WmsInventoryDetailDO.class, query); |
| 38 | 42 | } |
| 39 | 43 | |
| 44 | + private static void appendDaysToExpiresQuery(MPJLambdaWrapperX<WmsInventoryDetailDO> query, Integer daysToExpires) { | |
| 45 | + if (daysToExpires == null) { | |
| 46 | + return; | |
| 47 | + } | |
| 48 | + LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); | |
| 49 | + query.geIfPresent(WmsInventoryDetailDO::getExpirationDate, startTime) | |
| 50 | + .leIfPresent(WmsInventoryDetailDO::getExpirationDate, startTime.plusDays(daysToExpires)); | |
| 51 | + } | |
| 52 | + | |
| 40 | 53 | private static void appendDimensionOrder(MPJLambdaWrapperX<WmsInventoryDetailDO> query, String type) { |
| 41 | 54 | if (StrUtil.equals(WmsInventoryDetailPageReqVO.TYPE_WAREHOUSE, type)) { |
| 42 | 55 | query.orderByAsc(WmsInventoryDetailDO::getWarehouseId) | ... | ... |
yudao-module-wms/src/test/resources/sql/clean.sql
yudao-module-wms/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -52,3 +52,27 @@ CREATE TABLE IF NOT EXISTS "wms_inventory" ( |
| 52 | 52 | "tenant_id" bigint NOT NULL DEFAULT '0', |
| 53 | 53 | PRIMARY KEY ("id") |
| 54 | 54 | ) COMMENT 'WMS 库存表'; |
| 55 | + | |
| 56 | +CREATE TABLE IF NOT EXISTS "wms_inventory_detail" ( | |
| 57 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 58 | + "sku_id" bigint NOT NULL, | |
| 59 | + "warehouse_id" bigint NOT NULL, | |
| 60 | + "area_id" bigint NOT NULL DEFAULT '0', | |
| 61 | + "quantity" decimal(24, 6) NOT NULL DEFAULT '0', | |
| 62 | + "remain_quantity" decimal(24, 6) NOT NULL DEFAULT '0', | |
| 63 | + "batch_no" varchar(64) DEFAULT NULL, | |
| 64 | + "production_date" timestamp DEFAULT NULL, | |
| 65 | + "expiration_date" timestamp DEFAULT NULL, | |
| 66 | + "amount" decimal(24, 6) DEFAULT NULL, | |
| 67 | + "remark" varchar(255) DEFAULT NULL, | |
| 68 | + "order_id" bigint DEFAULT NULL, | |
| 69 | + "order_no" varchar(64) DEFAULT NULL, | |
| 70 | + "order_type" tinyint DEFAULT NULL, | |
| 71 | + "creator" varchar(64) DEFAULT '', | |
| 72 | + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 73 | + "updater" varchar(64) DEFAULT '', | |
| 74 | + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 75 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 76 | + "tenant_id" bigint NOT NULL DEFAULT '0', | |
| 77 | + PRIMARY KEY ("id") | |
| 78 | +) COMMENT 'WMS 库存明细表'; | ... | ... |