Commit eb4224191c4c01d9552b852471ebf4416e6f9a8d
1 parent
28f62af7
feat(wms):增加 receipt order 实体
Showing
4 changed files
with
283 additions
and
2 deletions
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/order/receipt/WmsReceiptOrderDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.dataobject.order.receipt; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | |
| 5 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.warehouse.WmsWarehouseAreaDO; | |
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.warehouse.WmsWarehouseDO; | |
| 7 | +import cn.iocoder.yudao.module.wms.enums.DictTypeConstants; | |
| 8 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 10 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 11 | +import lombok.*; | |
| 12 | + | |
| 13 | +import java.math.BigDecimal; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * WMS 入库单 DO | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@TableName("wms_receipt_order") | |
| 21 | +@KeySequence("wms_receipt_order_seq") | |
| 22 | +@Data | |
| 23 | +@EqualsAndHashCode(callSuper = true) | |
| 24 | +@ToString(callSuper = true) | |
| 25 | +@Builder | |
| 26 | +@NoArgsConstructor | |
| 27 | +@AllArgsConstructor | |
| 28 | +public class WmsReceiptOrderDO extends BaseDO { | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 主键编号 | |
| 32 | + */ | |
| 33 | + @TableId | |
| 34 | + private Long id; | |
| 35 | + /** | |
| 36 | + * 入库单号 | |
| 37 | + */ | |
| 38 | + private String no; | |
| 39 | + /** | |
| 40 | + * 入库类型 | |
| 41 | + * | |
| 42 | + * 字典 {@link DictTypeConstants#RECEIPT_ORDER_TYPE} | |
| 43 | + */ | |
| 44 | + private Integer type; | |
| 45 | + /** | |
| 46 | + * 入库状态 | |
| 47 | + * | |
| 48 | + * 字典 {@link DictTypeConstants#RECEIPT_ORDER_STATUS} | |
| 49 | + */ | |
| 50 | + private Integer status; | |
| 51 | + /** | |
| 52 | + * 业务订单号 | |
| 53 | + */ | |
| 54 | + private String bizOrderNo; | |
| 55 | + /** | |
| 56 | + * 往来企业编号 | |
| 57 | + * | |
| 58 | + * 关联 {@link WmsMerchantDO#getId()} | |
| 59 | + */ | |
| 60 | + private Long merchantId; | |
| 61 | + /** | |
| 62 | + * 备注 | |
| 63 | + */ | |
| 64 | + private String remark; | |
| 65 | + | |
| 66 | + // ========= 仓库库区字段 ========= | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 仓库编号 | |
| 70 | + * | |
| 71 | + * 关联 {@link WmsWarehouseDO#getId()} | |
| 72 | + */ | |
| 73 | + private Long warehouseId; | |
| 74 | + /** | |
| 75 | + * 库区编号 | |
| 76 | + * | |
| 77 | + * 关联 {@link WmsWarehouseAreaDO#getId()} | |
| 78 | + */ | |
| 79 | + private Long areaId; | |
| 80 | + | |
| 81 | + // ========= 汇总金额字段 ========= | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 总数量 | |
| 85 | + */ | |
| 86 | + private BigDecimal totalQuantity; | |
| 87 | + /** | |
| 88 | + * 总金额 | |
| 89 | + */ | |
| 90 | + private BigDecimal totalAmount; | |
| 91 | + | |
| 92 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/order/receipt/WmsReceiptOrderDetailDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.dal.dataobject.order.receipt; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemSkuDO; | |
| 5 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.warehouse.WmsWarehouseAreaDO; | |
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.warehouse.WmsWarehouseDO; | |
| 7 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 10 | +import lombok.*; | |
| 11 | + | |
| 12 | +import java.math.BigDecimal; | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * WMS 入库单明细 DO | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@TableName("wms_receipt_order_detail") | |
| 21 | +@KeySequence("wms_receipt_order_detail_seq") | |
| 22 | +@Data | |
| 23 | +@EqualsAndHashCode(callSuper = true) | |
| 24 | +@ToString(callSuper = true) | |
| 25 | +@Builder | |
| 26 | +@NoArgsConstructor | |
| 27 | +@AllArgsConstructor | |
| 28 | +public class WmsReceiptOrderDetailDO extends BaseDO { | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 主键编号 | |
| 32 | + */ | |
| 33 | + @TableId | |
| 34 | + private Long id; | |
| 35 | + /** | |
| 36 | + * 备注 | |
| 37 | + */ | |
| 38 | + private String remark; | |
| 39 | + | |
| 40 | + // ========= 单据商品字段 ========= | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 入库单编号 | |
| 44 | + * | |
| 45 | + * 关联 {@link WmsReceiptOrderDO#getId()} | |
| 46 | + */ | |
| 47 | + private Long orderId; | |
| 48 | + /** | |
| 49 | + * 商品 SKU 编号 | |
| 50 | + * | |
| 51 | + * 关联 {@link WmsItemSkuDO#getId()} | |
| 52 | + */ | |
| 53 | + private Long skuId; | |
| 54 | + | |
| 55 | + // ========= 仓库库区字段 ========= | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 仓库编号 | |
| 59 | + * | |
| 60 | + * 关联 {@link WmsWarehouseDO#getId()} | |
| 61 | + */ | |
| 62 | + private Long warehouseId; | |
| 63 | + /** | |
| 64 | + * 库区编号 | |
| 65 | + * | |
| 66 | + * 关联 {@link WmsWarehouseAreaDO#getId()} | |
| 67 | + */ | |
| 68 | + private Long areaId; | |
| 69 | + | |
| 70 | + // ========= 批次效期字段 ========= | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 批号 | |
| 74 | + */ | |
| 75 | + private String batchNo; | |
| 76 | + /** | |
| 77 | + * 生产日期 | |
| 78 | + */ | |
| 79 | + private LocalDateTime productionDate; | |
| 80 | + /** | |
| 81 | + * 过期日期 | |
| 82 | + */ | |
| 83 | + private LocalDateTime expirationDate; | |
| 84 | + | |
| 85 | + // ========= 汇总金额字段 ========= | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * 入库数量 | |
| 89 | + */ | |
| 90 | + private BigDecimal quantity; | |
| 91 | + /** | |
| 92 | + * 金额(小计、非单价) | |
| 93 | + */ | |
| 94 | + private BigDecimal amount; | |
| 95 | + | |
| 96 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/DictTypeConstants.java
| ... | ... | @@ -8,8 +8,8 @@ package cn.iocoder.yudao.module.wms.enums; |
| 8 | 8 | public interface DictTypeConstants { |
| 9 | 9 | |
| 10 | 10 | String MERCHANT_TYPE = "merchant_type"; |
| 11 | - String RECEIPT_STATUS = "wms_receipt_status"; | |
| 12 | - String RECEIPT_TYPE = "wms_receipt_type"; | |
| 11 | + String RECEIPT_ORDER_STATUS = "wms_receipt_order_status"; | |
| 12 | + String RECEIPT_ORDER_TYPE = "wms_receipt_order_type"; | |
| 13 | 13 | String SHIPMENT_STATUS = "wms_shipment_status"; |
| 14 | 14 | String SHIPMENT_TYPE = "wms_shipment_type"; |
| 15 | 15 | String INVENTORY_HISTORY_TYPE = "wms_inventory_history_type"; | ... | ... |
yudao-module-wms/src/test/java/cn/iocoder/yudao/module/wms/service/inventory/WmsInventoryDetailServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.inventory; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.module.wms.controller.admin.inventory.vo.detail.WmsInventoryDetailPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.wms.dal.dataobject.inventory.WmsInventoryDetailDO; | |
| 7 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; | |
| 8 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemSkuDO; | |
| 9 | +import cn.iocoder.yudao.module.wms.dal.mysql.inventory.WmsInventoryDetailMapper; | |
| 10 | +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemMapper; | |
| 11 | +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemSkuMapper; | |
| 12 | +import jakarta.annotation.Resource; | |
| 13 | +import org.junit.jupiter.api.Test; | |
| 14 | +import org.springframework.context.annotation.Import; | |
| 15 | + | |
| 16 | +import java.math.BigDecimal; | |
| 17 | +import java.time.LocalDate; | |
| 18 | +import java.time.LocalDateTime; | |
| 19 | +import java.time.LocalTime; | |
| 20 | + | |
| 21 | +import static org.junit.jupiter.api.Assertions.assertEquals; | |
| 22 | + | |
| 23 | +@Import(WmsInventoryDetailServiceImpl.class) | |
| 24 | +public class WmsInventoryDetailServiceImplTest extends BaseDbUnitTest { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private WmsInventoryDetailServiceImpl inventoryDetailService; | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private WmsInventoryDetailMapper inventoryDetailMapper; | |
| 31 | + @Resource | |
| 32 | + private WmsItemMapper itemMapper; | |
| 33 | + @Resource | |
| 34 | + private WmsItemSkuMapper skuMapper; | |
| 35 | + | |
| 36 | + @Test | |
| 37 | + public void testGetInventoryDetailPage_daysToExpires() { | |
| 38 | + // mock 数据 | |
| 39 | + WmsItemDO item = createItem("ITEM-001", "红富士苹果"); | |
| 40 | + WmsItemSkuDO sku = createSku(item.getId(), "SKU-001", "10kg 箱装"); | |
| 41 | + WmsInventoryDetailDO dbDetail = createInventoryDetail(sku.getId(), 100L, 1001L, "10.00", | |
| 42 | + LocalDateTime.of(LocalDate.now().plusDays(10), LocalTime.MIN)); | |
| 43 | + inventoryDetailMapper.insert(dbDetail); | |
| 44 | + inventoryDetailMapper.insert(createInventoryDetail(sku.getId(), 100L, 1002L, "20.00", | |
| 45 | + LocalDateTime.of(LocalDate.now().plusDays(40), LocalTime.MIN))); | |
| 46 | + // 准备参数 | |
| 47 | + WmsInventoryDetailPageReqVO reqVO = new WmsInventoryDetailPageReqVO(); | |
| 48 | + reqVO.setType(WmsInventoryDetailPageReqVO.TYPE_WAREHOUSE); | |
| 49 | + reqVO.setDaysToExpires(30); | |
| 50 | + | |
| 51 | + // 调用 | |
| 52 | + PageResult<WmsInventoryDetailDO> pageResult = inventoryDetailService.getInventoryDetailPage(reqVO); | |
| 53 | + // 断言 | |
| 54 | + assertEquals(1, pageResult.getTotal()); | |
| 55 | + assertEquals(1, pageResult.getList().size()); | |
| 56 | + assertEquals(dbDetail.getId(), pageResult.getList().get(0).getId()); | |
| 57 | + } | |
| 58 | + | |
| 59 | + private WmsItemDO createItem(String code, String name) { | |
| 60 | + WmsItemDO item = WmsItemDO.builder() | |
| 61 | + .code(code) | |
| 62 | + .name(name) | |
| 63 | + .unit("箱") | |
| 64 | + .categoryId(1L) | |
| 65 | + .build(); | |
| 66 | + itemMapper.insert(item); | |
| 67 | + return item; | |
| 68 | + } | |
| 69 | + | |
| 70 | + private WmsItemSkuDO createSku(Long itemId, String code, String name) { | |
| 71 | + WmsItemSkuDO sku = WmsItemSkuDO.builder() | |
| 72 | + .itemId(itemId) | |
| 73 | + .code(code) | |
| 74 | + .name(name) | |
| 75 | + .barCode("69010001") | |
| 76 | + .build(); | |
| 77 | + skuMapper.insert(sku); | |
| 78 | + return sku; | |
| 79 | + } | |
| 80 | + | |
| 81 | + private static WmsInventoryDetailDO createInventoryDetail(Long skuId, Long warehouseId, Long areaId, | |
| 82 | + String quantity, LocalDateTime expirationDate) { | |
| 83 | + return WmsInventoryDetailDO.builder() | |
| 84 | + .skuId(skuId) | |
| 85 | + .warehouseId(warehouseId) | |
| 86 | + .areaId(areaId) | |
| 87 | + .quantity(new BigDecimal(quantity)) | |
| 88 | + .remainQuantity(new BigDecimal(quantity)) | |
| 89 | + .expirationDate(expirationDate) | |
| 90 | + .build(); | |
| 91 | + } | |
| 92 | + | |
| 93 | +} | ... | ... |