|
|
@@ -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);
|