|
|
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -53,10 +54,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -111,9 +109,9 @@ public class StockDescController extends BladeController {
|
|
|
.like(ObjectUtil.isNotEmpty(stockDesc.getDot()), PjStockDesc::getDot, stockDesc.getDot())
|
|
|
.orderByDesc(PjStockDesc::getBalanceQuantity);
|
|
|
String appWhetherZeroInventory = iSysClient.getParamService("app.whether.zero.inventory");
|
|
|
- if ("0".equals(appWhetherZeroInventory)){
|
|
|
+ if ("0".equals(appWhetherZeroInventory)) {
|
|
|
lambdaQueryWrapper.ne(PjStockDesc::getBalanceQuantity, 0);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if ("0".equals(stockDesc.getWhether())) {
|
|
|
lambdaQueryWrapper.ne(PjStockDesc::getBalanceQuantity, 0);
|
|
|
}
|
|
|
@@ -299,7 +297,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
if (ObjectUtil.isNotEmpty(stockDesc.getCname())) {
|
|
|
List<PjGoodsDesc> pjGoodsDescs = goodsDescService.list(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -451,7 +449,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
if (ObjectUtil.isNotEmpty(stockDesc.getCname())) {
|
|
|
List<PjGoodsDesc> pjGoodsDescs = goodsDescService.list(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -525,8 +523,8 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageName()), PjStockDesc::getStorageName, stockDesc.getStorageName());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageName()), PjStockDesc::getStorageName, stockDesc.getStorageName());
|
|
|
List<PjProductLaunch> pjProductLaunchList = new ArrayList<>();
|
|
|
if (ObjectUtil.isNotEmpty(stockDesc.getCname())) {
|
|
|
List<PjGoodsDesc> pjGoodsDescs = new ArrayList<>();
|
|
|
@@ -676,7 +674,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
|
|
|
List<StockBrandExcel> mapList = new ArrayList<>();
|
|
|
if (!list.isEmpty()) {
|
|
|
@@ -798,7 +796,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
|
|
|
List<StockBrandExcel> stockBrandExcelList = new ArrayList<>();
|
|
|
if (!list.isEmpty()) {
|
|
|
@@ -924,7 +922,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
|
|
|
return R.data(list);
|
|
|
}
|
|
|
@@ -947,7 +945,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
List<PjStockDesc> list = stockDescService.list(lambdaQueryWrapper);
|
|
|
return R.data(list);
|
|
|
}
|
|
|
@@ -1038,7 +1036,7 @@ public class StockDescController extends BladeController {
|
|
|
if (ObjectUtils.isNotNull(ParameterUtils.getStorageId()) && ParameterUtils.whetherDatabaseSharding()) {
|
|
|
lambdaQueryWrapper.apply("find_in_set(storage_id,'" + ParameterUtils.getStorageId() + "')");
|
|
|
}
|
|
|
- lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
+ lambdaQueryWrapper.eq(ObjectUtil.isNotEmpty(stockDesc.getStorageId()), PjStockDesc::getStorageId, stockDesc.getStorageId());
|
|
|
PjProductLaunch productLaunch = null;
|
|
|
if (ObjectUtil.isNotEmpty(stockDesc.getCname())) {
|
|
|
PjGoodsDesc pjGoodsDescs = goodsDescService.getOne(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
@@ -1062,6 +1060,8 @@ public class StockDescController extends BladeController {
|
|
|
}
|
|
|
lambdaQueryWrapper.orderByDesc(PjStockDesc::getBalanceQuantity);
|
|
|
IPage<PjStockDesc> pages = stockDescService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
+ IPage<PjStockDesc> stockDescIPage = new Page<>();
|
|
|
+ List<PjStockDesc> stockDescList = new ArrayList<>();
|
|
|
if (!pages.getRecords().isEmpty()) {
|
|
|
List<PjGoodsFiles> goodsFilesList = new ArrayList<>();
|
|
|
List<PjBrandFiles> pjBrandFilesList = new ArrayList<>();
|
|
|
@@ -1121,7 +1121,20 @@ public class StockDescController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ List<PjStockDesc> stockDescs = pages.getRecords().stream().collect(Collectors.collectingAndThen(
|
|
|
+ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(p -> p.getGoodsId() + "," + p.getStorageId()))), ArrayList::new));
|
|
|
+ for (PjStockDesc item : stockDescs) {
|
|
|
+ BigDecimal balanceQuantity = pages.getRecords().stream().filter(e -> e.getStorageId().equals(item.getStorageId()) &&
|
|
|
+ e.getGoodsId().equals(item.getGoodsId())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ item.setBalanceQuantity(balanceQuantity);
|
|
|
+ stockDescList.add(item);
|
|
|
+ }
|
|
|
}
|
|
|
- return R.data(pages);
|
|
|
+ stockDescIPage.setRecords(stockDescList);
|
|
|
+ stockDescIPage.setTotal(pages.getTotal());
|
|
|
+ stockDescIPage.setPages(pages.getPages());
|
|
|
+ stockDescIPage.setCurrent(pages.getCurrent());
|
|
|
+ stockDescIPage.setSize(pages.getSize());
|
|
|
+ return R.data(stockDescIPage);
|
|
|
}
|
|
|
}
|