Skip to content

Commit

Permalink
Merge pull request #354 from Jzow/master
Browse files Browse the repository at this point in the history
Synchronize the modification of backend and fortend business
  • Loading branch information
Jzow authored Aug 15, 2024
2 parents 46355ba + 525ce73 commit 7be6f24
Show file tree
Hide file tree
Showing 39 changed files with 1,007 additions and 644 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
import com.wansenai.api.RateLimitException;
import com.wansenai.api.config.RateLimiter;
import com.wansenai.service.common.CommonService;
import com.wansenai.utils.ExcelUtil;
import com.wansenai.utils.enums.LimitType;
import com.wansenai.utils.response.Response;
import com.wansenai.utils.constants.ApiVersionConstants;
import com.wansenai.utils.enums.BaseCodeEnum;
import com.wansenai.vo.CaptchaVO;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;


Expand Down Expand Up @@ -74,32 +71,12 @@ public Response<String> uploadExclsData(@RequestParam("file") MultipartFile file
return commonService.uploadExclsData(file);
}


@PostMapping("upload/productCoverUpload")
public Response<String> productCoverUpload(@RequestParam("file") MultipartFile file, @RequestParam("type") Integer type) {
return commonService.productCoverUpload(file, type);
}

/**
* @deprecatedjavadoc
*
* At present, exporting requires filtering based on query conditions, and the exportExcel method exports all data.
* It is more of a universal export method, and the implementation class of the method needs to match the array
* index mapping of exported columns, which is very complex. Therefore, it will be removed in the next version
*
* @param type export type name
* @param response HttpServletResponse object file
*/
@GetMapping("/export/excel")
@Deprecated(since = "2.1.0", forRemoval = true)
public void exportExcel(@RequestParam("type") String type, HttpServletResponse response) {
try {
File file = commonService.exportExcel(type);
ExcelUtil.downloadExcel(file, file.getName(), response);
}catch (Exception e) {
log.error("导出excel异常", e);
}
}

@PostMapping("uploadOss")
public Response<List<String>> uploadOss(@RequestParam("files") List<MultipartFile> files) {
return commonService.uploadOss(files);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.wansenai.utils.response.Response;
import com.wansenai.vo.product.ProductDetailVO;
import com.wansenai.vo.product.ProductVO;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand Down Expand Up @@ -76,4 +77,9 @@ public Response<String> updateProductStatus(@PathVariable List<Long> productIds,
public Response<String> updateBatchProductInfo(@RequestBody UpdateBatchProductDTO updateBatchProductDTO) {
return productService.updateBatchProductInfo(updateBatchProductDTO);
}

@GetMapping("export")
public void exportProductExcel(@ModelAttribute QueryProductDTO queryProductDTO , HttpServletResponse response) throws Exception {
productService.exportProductExcel(queryProductDTO, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Response<ProductStockKeepUnitVO> getProductByBarCode(@PathVariable("barCo
}

@PostMapping("productStockSku")
public Response<List<ProductStockSkuVO>> getProductStockInfo(@RequestBody QueryProductStockDTO queryProductStockDTO) {
return productStockService.getProductStockSkuList(queryProductStockDTO);
public Response<List<ProductStockSkuVO>> getProductStockInfo() {
return productStockService.getProductStockSkuList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public interface ProductStockMapper extends BaseMapper<ProductStock> {

Page<ProductStockSkuVO> getProductStock(IPage<QueryProductStockDTO> pageObject, QueryProductStockDTO queryProductStockDTO);

List<ProductStockSkuVO> getProductStockList(QueryProductStockDTO queryProductStockDTO);
List<ProductStockSkuVO> getProductStockListByTerms(QueryProductStockDTO queryProductStockDTO);

List<ProductStockSkuVO> getProductStockList();

// 检查商品是否存在
Boolean productStockExist(Long productSkuId, Long warehouseId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@
</where>
</select>

<select id="getProductStockList" resultType="com.wansenai.vo.report.ProductStockSkuVO" parameterType="com.wansenai.dto.report.QueryProductStockDTO">
<select id="getProductStockListByTerms" resultType="com.wansenai.vo.report.ProductStockSkuVO" parameterType="com.wansenai.dto.report.QueryProductStockDTO">
SELECT ps.id, p.product_name, p.id AS productId, p.product_model, p.product_standard, p.product_color,sku.product_bar_code, p.product_weight, p.warehouse_shelves,
sku.product_unit, sku.retail_price, sku.sale_price, sku.purchase_price, p.product_manufacturer,pc.category_name AS product_category_name,
ps.current_stock_quantity AS current_stock, ps.init_stock_quantity AS initial_stock, w.warehouse_name, w.id AS warehouseId,
ROUND((ps.current_stock_quantity * sku.retail_price), 2) AS stock_amount
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
INNER JOIN warehouse as w ON ps.warehouse_id = w.id
INNER JOIN product_sku AS sku ON sku.id = ps.product_sku_id
INNER 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="productCategoryId != null">
Expand All @@ -145,6 +145,18 @@
</where>
</select>

<select id="getProductStockList" resultType="com.wansenai.vo.report.ProductStockSkuVO">
SELECT ps.id, p.product_name, p.id AS productId, p.product_model, p.product_standard, p.product_color,sku.product_bar_code, p.product_weight, p.warehouse_shelves,
sku.product_unit, sku.retail_price, sku.sale_price, sku.purchase_price, p.product_manufacturer,pc.category_name AS product_category_name,
ps.current_stock_quantity AS current_stock, ps.init_stock_quantity AS initial_stock, w.warehouse_name, w.id AS warehouseId,
ROUND((ps.current_stock_quantity * sku.retail_price), 2) AS stock_amount
FROM product_stock AS ps
INNER JOIN warehouse as w ON ps.warehouse_id = w.id
INNER JOIN product_sku AS sku ON sku.id = ps.product_sku_id
INNER JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
</select>

<select id="productStockExist" resultType="boolean" parameterType="map">
SELECT COUNT(1) > 0
FROM product_stock
Expand All @@ -154,7 +166,7 @@

<insert id="saveBatch" parameterType="java.util.List">
INSERT INTO product_stock (id, tenant_id, product_sku_id, warehouse_id,
init_stock_quantity, high_stock_quantity, current_stock_quantity, create_time, update_time, create_by, update_by, delete_flag)
init_stock_quantity, high_stock_quantity, current_stock_quantity, create_time, update_time, create_by, update_by, delete_flag)
VALUES
<foreach collection="list" item="item" separator=",">
(
Expand Down
105 changes: 105 additions & 0 deletions core/domain/src/main/java/com/wansenai/bo/product/ExportProductBO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright 2024-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.bo.product;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.bo.BigDecimalSerializerBO;
import com.wansenai.utils.excel.ExcelExport;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExportProductBO {

@ExcelExport(value = "商品名称")
private String productName;

@ExcelExport(value = "条码")
private String productBarcode;

@ExcelExport(value = "商品单位")
private String productUnit;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "库存")
private BigDecimal stock;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "零售价格")
private BigDecimal retailPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "销售价格")
private BigDecimal salesPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "采购价格")
private BigDecimal purchasePrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "最低销售价格")
private BigDecimal lowSalesPrice;

@ExcelExport(value = "规格")
private String productStandard;

@ExcelExport(value = "型号")
private String productModel;

@ExcelExport(value = "颜色")
private String productColor;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "商品重量")
private BigDecimal productWeight;

@ExcelExport(value = "保质期")
private Integer productExpiryNum;

@ExcelExport(value = "类别")
private String productCategoryName;

@ExcelExport(value = "序列号")
private String enableSerialNumber;

@ExcelExport(value = "批次号")
private String enableBatchNumber;

@ExcelExport(value = "仓库货架")
private String warehouseShelves;

@ExcelExport(value = "制造商")
private String productManufacturer;

@ExcelExport(value = "商品属性")
private String multiAttribute;

@ExcelExport(value = "自定义1")
private String otherFieldOne;

@ExcelExport(value = "自定义2")
private String otherFieldTwo;

@ExcelExport(value = "自定义3")
private String otherFieldThree;

@ExcelExport(value = "备注")
private String remark;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright 2024-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.bo.product;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.bo.BigDecimalSerializerBO;
import com.wansenai.utils.excel.ExcelExport;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExportProductEnBO {

@ExcelExport(value = "Name of commodity")
private String productName;

@ExcelExport(value = "Bar code")
private String productBarcode;

@ExcelExport(value = "Commodity measurement unit")
private String productUnit;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "Current inventory quantity")
private BigDecimal stock;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "Retail price")
private BigDecimal retailPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "Market price")
private BigDecimal salesPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "Purchase price")
private BigDecimal purchasePrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "Minimum selling price")
private BigDecimal lowSalesPrice;

@ExcelExport(value = "Specifications")
private String productStandard;

@ExcelExport(value = "Model")
private String productModel;

@ExcelExport(value = "Color")
private String productColor;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "Base weight")
private BigDecimal productWeight;

@ExcelExport(value = "Guarantee period")
private Integer productExpiryNum;

@ExcelExport(value = "Category")
private String productCategoryName;

@ExcelExport(value = "Serial number")
private String enableSerialNumber;

@ExcelExport(value = "Batch number")
private String enableBatchNumber;

@ExcelExport(value = "Position shelf")
private String warehouseShelves;

@ExcelExport(value = "Manufacturer")
private String productManufacturer;

@ExcelExport(value = "Multiple attributes")
private String multiAttribute;

@ExcelExport(value = "Extended field 1")
private String otherFieldOne;

@ExcelExport(value = "Extended field 2")
private String otherFieldTwo;

@ExcelExport(value = "Extended field 3")
private String otherFieldThree;

@ExcelExport(value = "Remark")
private String remark;
}
Loading

0 comments on commit 7be6f24

Please sign in to comment.