Browse Source

2024年7月1日17:28:06

纪新园 1 year ago
parent
commit
6423ca8112

+ 59 - 0
blade-service-api/blade-sales-part-api/src/main/java/org/springblade/salesPart/excel/StockBrandExcel.java

@@ -0,0 +1,59 @@
+package org.springblade.salesPart.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 库存导出实体类
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class StockBrandExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 品牌
+	 */
+	@ExcelProperty(value = "品牌")
+	private String brandName;
+	/**
+	 * 15
+	 */
+	@ExcelProperty(value = "15")
+	private BigDecimal goodsSize15;
+	/**
+	 * 16
+	 */
+	@ExcelProperty(value = "16")
+	private BigDecimal goodsSize16;
+	/**
+	 * 17
+	 */
+	@ExcelProperty(value = "17")
+	private BigDecimal goodsSize17;
+	/**
+	 * 18
+	 */
+	@ExcelProperty(value = "18")
+	private BigDecimal goodsSize18;
+	/**
+	 * 19
+	 */
+	@ExcelProperty(value = "19")
+	private BigDecimal goodsSize19;
+
+	/**
+	 * 其他
+	 */
+	@ExcelProperty(value = "其他")
+	private BigDecimal goodsSizeOther;
+}

+ 1 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/corps/service/impl/CorpsDescServiceImpl.java

@@ -195,6 +195,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 		List<PjCorpsDesc> pjCorpsDesc = baseMapper.selectList(new LambdaQueryWrapper<PjCorpsDesc>()
 			.eq(PjCorpsDesc::getTenantId, AuthUtil.getTenantId())
 			.eq(PjCorpsDesc::getIsDeleted, 0)
+			.eq(PjCorpsDesc::getSalesCompanyId, AuthUtil.getTenantId())
 			.eq(PjCorpsDesc::getCname, corpsDesc.getCname()));
 		//保存客户信息
 		if (corpsDesc.getId() == null) {

+ 98 - 1
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/stock/controller/StockDescController.java

@@ -37,6 +37,7 @@ import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.salesPart.brand.service.IBrandFigureService;
 import org.springblade.salesPart.brand.service.IBrandFilesService;
 import org.springblade.salesPart.entity.*;
+import org.springblade.salesPart.excel.StockBrandExcel;
 import org.springblade.salesPart.excel.StockExportExcel;
 import org.springblade.salesPart.goods.service.IGoodsDescService;
 import org.springblade.salesPart.goods.service.IGoodsFilesService;
@@ -534,6 +535,102 @@ public class StockDescController extends BladeController {
 	}
 
 	/**
+	 * 库存查询(品牌)
+	 */
+	@GetMapping("/stockBrandList")
+	public R stockBrandList(PjStockDesc stockDesc) {
+		LambdaQueryWrapper<PjStockDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+		lambdaQueryWrapper.eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
+			.eq(PjStockDesc::getIsDeleted, 0)
+			.eq(PjStockDesc::getSalesCompanyId, AuthUtil.getDeptId())//公司
+			.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId())
+			.eq(ObjectUtil.isNotEmpty(stockDesc.getBrandId()), PjStockDesc::getBrandId, stockDesc.getBrandId())
+			.orderByAsc(PjStockDesc::getCreateTime);
+		List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
+		List<StockBrandExcel> mapList = new ArrayList<>();
+		if (!list.isEmpty()) {
+			List<String> brandNames = list.stream().map(PjStockDesc::getBrandName).distinct().collect(Collectors.toList());
+			List<PjGoodsDesc> pjGoodsDescs = goodsDescService.list(new LambdaQueryWrapper<PjGoodsDesc>()
+				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
+				.eq(PjGoodsDesc::getIsDeleted, 0)
+				.eq(PjGoodsDesc::getSalesCompanyId, AuthUtil.getDeptId()));
+			List<Long> ids15 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("15")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids16 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("16")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids17 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("17")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids18 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("18")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids19 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("19")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> idsOther = pjGoodsDescs.stream().filter(e -> !e.getGoodsSize().equals("15") && !e.getGoodsSize().equals("16")
+					&& !e.getGoodsSize().equals("17") && !e.getGoodsSize().equals("18") && !e.getGoodsSize().equals("19"))
+				.map(PjGoodsDesc::getId).distinct().collect(Collectors.toList());
+			for (String item : brandNames) {
+				StockBrandExcel stockBrandExcel = new StockBrandExcel();
+				stockBrandExcel.setBrandName(item);
+				stockBrandExcel.setGoodsSize15( list.stream().filter(e -> ids15.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize16( list.stream().filter(e -> ids16.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize17( list.stream().filter(e -> ids17.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize18( list.stream().filter(e -> ids18.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize19( list.stream().filter(e -> ids19.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSizeOther( list.stream().filter(e -> idsOther.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				mapList.add(stockBrandExcel);
+			}
+		}
+		return R.data(mapList);
+	}
+
+	/**
+	 * 库存查询(品牌)导出
+	 */
+	@GetMapping("/stockBrandExport")
+	public void stockBrandExport(PjStockDesc stockDesc, HttpServletResponse response) {
+		LambdaQueryWrapper<PjStockDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+		lambdaQueryWrapper.eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
+			.eq(PjStockDesc::getIsDeleted, 0)
+			.eq(PjStockDesc::getSalesCompanyId, AuthUtil.getDeptId())//公司
+			.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId())
+			.eq(ObjectUtil.isNotEmpty(stockDesc.getBrandId()), PjStockDesc::getBrandId, stockDesc.getBrandId())
+			.orderByAsc(PjStockDesc::getCreateTime);
+		List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
+		List<StockBrandExcel> stockBrandExcelList = new ArrayList<>();
+		if (!list.isEmpty()) {
+			List<String> brandNames = list.stream().map(PjStockDesc::getBrandName).distinct().collect(Collectors.toList());
+			List<PjGoodsDesc> pjGoodsDescs = goodsDescService.list(new LambdaQueryWrapper<PjGoodsDesc>()
+				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
+				.eq(PjGoodsDesc::getIsDeleted, 0)
+				.eq(PjGoodsDesc::getSalesCompanyId, AuthUtil.getDeptId()));
+			List<Long> ids15 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("15")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids16 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("16")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids17 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("17")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids18 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("18")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> ids19 = pjGoodsDescs.stream().filter(e -> e.getGoodsSize().equals("19")).map(PjGoodsDesc::getId)
+				.distinct().collect(Collectors.toList());
+			List<Long> idsOther = pjGoodsDescs.stream().filter(e -> !e.getGoodsSize().equals("15") && !e.getGoodsSize().equals("16")
+					&& !e.getGoodsSize().equals("17") && !e.getGoodsSize().equals("18") && !e.getGoodsSize().equals("19"))
+				.map(PjGoodsDesc::getId).distinct().collect(Collectors.toList());
+			for (String item : brandNames) {
+				StockBrandExcel stockBrandExcel = new StockBrandExcel();
+				stockBrandExcel.setBrandName(item);
+				stockBrandExcel.setGoodsSize15( list.stream().filter(e -> ids15.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize16( list.stream().filter(e -> ids16.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize17( list.stream().filter(e -> ids17.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize18( list.stream().filter(e -> ids18.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSize19( list.stream().filter(e -> ids19.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcel.setGoodsSizeOther( list.stream().filter(e -> idsOther.contains(e.getGoodsId()) && item.equals(e.getBrandName())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+				stockBrandExcelList.add(stockBrandExcel);
+			}
+		}
+		ExcelUtil.export(response, "库存查询-品牌", "库存查询-品牌", stockBrandExcelList, StockBrandExcel.class);
+	}
+
+	/**
 	 * 根据仓库和商品id获得所有批次号
 	 */
 	@GetMapping("/dotList")
@@ -546,7 +643,7 @@ public class StockDescController extends BladeController {
 			.eq(PjStockDesc::getSalesCompanyId, AuthUtil.getDeptId())//公司
 			.eq(ObjectUtils.isNotNull(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId())
 			.eq(PjStockDesc::getGoodsId, stockDesc.getGoodsId())
-			.eq(ObjectUtils.isNotNull(stockDesc.getDot()),PjStockDesc::getDot, stockDesc.getDot());
+			.eq(ObjectUtils.isNotNull(stockDesc.getDot()), PjStockDesc::getDot, stockDesc.getDot());
 
 		List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
 		return R.data(list);