Skip to content

Commit

Permalink
Merge pull request #194 from Jzow/master
Browse files Browse the repository at this point in the history
Adjusting the interface regarding the inventory dao layer
  • Loading branch information
Jzow authored Nov 15, 2023
2 parents d39c8ff + 3a0005a commit 3cb48b1
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wansenai.dto.product.QueryProductStockKeepUnitDTO;
import com.wansenai.service.product.ProductStockKeepUnitService;
import com.wansenai.service.product.ProductStockService;
import com.wansenai.utils.enums.BaseCodeEnum;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.product.ProductStockKeepUnitVO;
Expand All @@ -32,15 +33,15 @@
@RequestMapping("/product/sku")
public class ProductStockKeepUnitController {

private final ProductStockKeepUnitService productStockKeepUnitService;
private final ProductStockService productStockService;

public ProductStockKeepUnitController(ProductStockKeepUnitService productStockKeepUnitService) {
this.productStockKeepUnitService = productStockKeepUnitService;
public ProductStockKeepUnitController(ProductStockService productStockService) {
this.productStockService = productStockService;
}

@PostMapping("pageList")
public Response<IPage<ProductStockKeepUnitVO>> getProductExtendPrice(@RequestBody QueryProductStockKeepUnitDTO priceDTO) {
var result = productStockKeepUnitService.getProductExtendPriceInfo(priceDTO);
var result = productStockService.getProductExtendPriceInfo(priceDTO);
if(result != null) {
return Response.responseData(result);
}
Expand All @@ -49,6 +50,6 @@ public Response<IPage<ProductStockKeepUnitVO>> getProductExtendPrice(@RequestBod

@GetMapping("getProduct/{barCode}/{warehouseId}")
public Response<ProductStockKeepUnitVO> getProductByBarCode(@PathVariable("barCode") Long barCode, @PathVariable("warehouseId")Long warehouseId) {
return productStockKeepUnitService.getProductByBarCode(barCode, warehouseId);
return productStockService.getProductByBarCode(barCode, warehouseId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
*/
package com.wansenai.api.report;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.report.QueryProductStock;
import com.wansenai.service.receipt.ReceiptRetailService;
import com.wansenai.service.receipt.ReceiptService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.receipt.retail.RetailStatisticalDataVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wansenai.vo.report.ProductStockVO;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/report")
Expand All @@ -34,4 +35,9 @@ public ReportController(ReceiptService receiptService) {
public Response<RetailStatisticalDataVO> getStatisticalData() {
return receiptService.getRetailStatistics();
}

@PostMapping("productStock")
public Response<Page<ProductStockVO>> getProductStock(@RequestBody QueryProductStock queryProductStock) {
return receiptService.getProductStock(queryProductStock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
* and limitations under the License.
*/
package com.wansenai.mappers.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wansenai.dto.product.QueryProductStockKeepUnitDTO;
import com.wansenai.entities.product.ProductStockKeepUnit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wansenai.vo.product.ProductStockKeepUnitVO;

/**
* <p>
Expand All @@ -25,9 +21,4 @@
*/
public interface ProductStockKeepUnitMapper extends BaseMapper<ProductStockKeepUnit> {

IPage<ProductStockKeepUnitVO> getProductSkuList(IPage<QueryProductStockKeepUnitDTO> pageObject, QueryProductStockKeepUnitDTO queryProductStockKeepUnitDTO);

ProductStockKeepUnitVO getProductSkuByBarCode(Long barCode, Long warehouseId);

ProductStockKeepUnitVO getProductSkuDetail(Long productId, Long warehouseId, Long barCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
*/
package com.wansenai.mappers.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wansenai.dto.product.QueryProductStockKeepUnitDTO;
import com.wansenai.dto.report.QueryProductStock;
import com.wansenai.entities.product.ProductStock;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wansenai.vo.product.ProductStockKeepUnitVO;
import com.wansenai.vo.report.ProductStockVO;

/**
* <p>
Expand All @@ -22,4 +27,12 @@
*/
public interface ProductStockMapper extends BaseMapper<ProductStock> {

IPage<ProductStockKeepUnitVO> getProductSkuList(IPage<QueryProductStockKeepUnitDTO> pageObject, QueryProductStockKeepUnitDTO queryProductStockKeepUnitDTO);

ProductStockKeepUnitVO getProductSkuByBarCode(Long barCode, Long warehouseId);

ProductStockKeepUnitVO getProductSkuDetail(Long productId, Long warehouseId, Long barCode);

IPage<ProductStockVO> getProductStock(IPage<QueryProductStock> pageObject, QueryProductStock queryProductStock);

}
Original file line number Diff line number Diff line change
@@ -1,71 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wansenai.mappers.product.ProductStockKeepUnitMapper">
<resultMap id="productResultMap" type="com.wansenai.vo.product.ProductStockKeepUnitVO">
<id property="id" column="id" />
<result property="productId" column="productId" />
<result property="productCategoryId" column="product_category_id" />
<result property="barCode" column="product_bar_code" />
<result property="productName" column="product_name" />
<result property="productCategoryName" column="category_name" />
<result property="productStandard" column="product_standard" />
<result property="productModel" column="product_model" />
<result property="productColor" column="product_color" />
<result property="productUnit" column="product_unit" />
<result property="multiAttribute" column="multi_attribute" />
<result property="stock" column="current_stock_quantity" />
<result property="extendInfo" column="product_manufacturer" />
<result property="retailPrice" column="retail_price" />
</resultMap>

<select id="getProductSkuList" resultMap="productResultMap" parameterType="com.baomidou.mybatisplus.core.metadata.IPage">
SELECT ps.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,pc.category_name,
ps.current_stock_quantity, w.warehouse_name, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN warehouse as w ON ps.warehouse_id = w.id
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
<where>
<if test="queryProductStockKeepUnitDTO.productCategoryId != null">
AND p.product_category_id = #{queryProductStockKeepUnitDTO.productCategoryId}
</if>
<if test="queryProductStockKeepUnitDTO.warehouseId != null">
AND ps.warehouse_id = #{queryProductStockKeepUnitDTO.warehouseId}
</if>
<if test="queryProductStockKeepUnitDTO.productName != null">
AND p.product_name = #{queryProductStockKeepUnitDTO.productName}
</if>
<if test="queryProductStockKeepUnitDTO.enableSerialNumber != null">
AND p.enable_serial_number = #{queryProductStockKeepUnitDTO.enableSerialNumber}
</if>
<if test="queryProductStockKeepUnitDTO.enableBatchNumber != null">
AND p.enable_batch_number = #{queryProductStockKeepUnitDTO.enableBatchNumber}
</if>
</where>
</select>

<select id="getProductSkuByBarCode" resultMap="productResultMap">
SELECT sku.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,
pc.category_name, ps.current_stock_quantity, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
WHERE sku.product_bar_code = #{barCode} AND ps.warehouse_id = #{warehouseId}
</select>

<select id="getProductSkuDetail" resultMap="productResultMap">
SELECT sku.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,
pc.category_name, ps.current_stock_quantity, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
WHERE p.id= #{productId} AND ps.warehouse_id = #{warehouseId} AND sku.product_bar_code = #{barCode}
</select>

</mapper>
Original file line number Diff line number Diff line change
@@ -1,5 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wansenai.mappers.product.ProductStockMapper">
<resultMap id="productResultMap" type="com.wansenai.vo.product.ProductStockKeepUnitVO">
<id property="id" column="id" />
<result property="productId" column="productId" />
<result property="productCategoryId" column="product_category_id" />
<result property="barCode" column="product_bar_code" />
<result property="productName" column="product_name" />
<result property="productCategoryName" column="category_name" />
<result property="productStandard" column="product_standard" />
<result property="productModel" column="product_model" />
<result property="productColor" column="product_color" />
<result property="productUnit" column="product_unit" />
<result property="multiAttribute" column="multi_attribute" />
<result property="stock" column="current_stock_quantity" />
<result property="extendInfo" column="product_manufacturer" />
<result property="retailPrice" column="retail_price" />
</resultMap>

<resultMap id="productStockMap" type="com.wansenai.vo.report.ProductStockVO">
<id property="id" column="id" />
</resultMap>

<select id="getProductSkuList" resultMap="productResultMap" parameterType="com.baomidou.mybatisplus.core.metadata.IPage">
SELECT ps.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,pc.category_name,
ps.current_stock_quantity, w.warehouse_name, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN warehouse as w ON ps.warehouse_id = w.id
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
<where>
<if test="queryProductStockKeepUnitDTO.productCategoryId != null">
AND p.product_category_id = #{queryProductStockKeepUnitDTO.productCategoryId}
</if>
<if test="queryProductStockKeepUnitDTO.warehouseId != null">
AND ps.warehouse_id = #{queryProductStockKeepUnitDTO.warehouseId}
</if>
<if test="queryProductStockKeepUnitDTO.productName != null">
AND p.product_name = #{queryProductStockKeepUnitDTO.productName}
</if>
<if test="queryProductStockKeepUnitDTO.enableSerialNumber != null">
AND p.enable_serial_number = #{queryProductStockKeepUnitDTO.enableSerialNumber}
</if>
<if test="queryProductStockKeepUnitDTO.enableBatchNumber != null">
AND p.enable_batch_number = #{queryProductStockKeepUnitDTO.enableBatchNumber}
</if>
</where>
</select>

<select id="getProductSkuByBarCode" resultMap="productResultMap">
SELECT sku.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,
pc.category_name, ps.current_stock_quantity, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
WHERE sku.product_bar_code = #{barCode} AND ps.warehouse_id = #{warehouseId}
</select>

<select id="getProductSkuDetail" resultMap="productResultMap">
SELECT sku.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,
pc.category_name, ps.current_stock_quantity, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
WHERE p.id= #{productId} AND ps.warehouse_id = #{warehouseId} AND sku.product_bar_code = #{barCode}
</select>

<select id="getProductStock" resultMap="productStockMap" parameterType="com.baomidou.mybatisplus.core.metadata.IPage">
SELECT ps.id, p.product_name, p.product_model, p.product_standard, p.product_color,sku.product_bar_code, sku.multi_attribute,
sku.product_unit, sku.retail_price, p.product_manufacturer,pc.category_name,
ps.current_stock_quantity, w.warehouse_name, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN warehouse as w ON ps.warehouse_id = w.id
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_stock AS sk ON sk.product_sku_id = sku.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
<where>
<if test="queryProductStock.productCategoryId != null">
AND p.product_category_id = #{queryProductStock.productCategoryId}
</if>
<if test="queryProductStock.warehouseId != null">
AND ps.warehouse_id = #{queryProductStock.warehouseId}
</if>
<if test="queryProductStock.productName != null">
AND p.product_name = #{queryProductStock.productName}
</if>
</where>
</select>
</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.dto.report;

import lombok.Data;

@Data
public class QueryProductStock {

private Long warehouseId;

private String productInfo;

private Long productCategoryId;

private String warehouseShelves;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.vo.report;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.bo.BigDecimalSerializerBO;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class ProductStockVO {

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long Id;

private String productBarcode;

private String productName;

private String productCategoryName;

private String productStandard;

private String productModel;

private String productColor;

private String productUnit;

private String warehouseShelves;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal productWeight;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal unitPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal initialStock;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal currentStock;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal stockAmount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ public interface ProductStockKeepUnitService extends IService<ProductStockKeepUn
Response<Long> getProductCode();

Boolean checkProductCode(List<String> barCodes);

IPage<ProductStockKeepUnitVO> getProductExtendPriceInfo(QueryProductStockKeepUnitDTO priceDTO);

Response<ProductStockKeepUnitVO> getProductByBarCode(Long barCode, Long warehouseId);
}
Loading

0 comments on commit 3cb48b1

Please sign in to comment.