|
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.exception.CustomPromptException;
|
|
import com.sckw.core.exception.CustomPromptException;
|
|
@@ -204,6 +203,13 @@ public class KwpGoodsService {
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return detail;
|
|
return detail;
|
|
|
}
|
|
}
|
|
|
|
|
+ Map<String, String> unitMap;
|
|
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.UNIT_TYPE.getType()));
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
|
|
+ unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ unitMap = new HashMap<>();
|
|
|
|
|
+ }
|
|
|
List<Long> goodsIds = list.stream().map(KwpGoods::getId).toList();
|
|
List<Long> goodsIds = list.stream().map(KwpGoods::getId).toList();
|
|
|
Map<Long, List<KwpGoodsPriceRange>> map = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
|
|
Map<Long, List<KwpGoodsPriceRange>> map = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
|
|
|
.collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
.collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
@@ -211,7 +217,7 @@ public class KwpGoodsService {
|
|
|
list.forEach(e -> {
|
|
list.forEach(e -> {
|
|
|
RecommendGoods recommendGoods = BeanUtils.copyProperties(e, RecommendGoods.class);
|
|
RecommendGoods recommendGoods = BeanUtils.copyProperties(e, RecommendGoods.class);
|
|
|
List<KwpGoodsPriceRange> prices = map.get(recommendGoods.getId());
|
|
List<KwpGoodsPriceRange> prices = map.get(recommendGoods.getId());
|
|
|
- recommendGoods.setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), recommendGoods.getUnit()))
|
|
|
|
|
|
|
+ recommendGoods.setUnitLabel(unitMap.get(recommendGoods.getUnit()))
|
|
|
.setPrice(CollectionUtils.isNotEmpty(prices) ? prices.get(0).getPrice() : null);
|
|
.setPrice(CollectionUtils.isNotEmpty(prices) ? prices.get(0).getPrice() : null);
|
|
|
recommendGoodsList.add(recommendGoods);
|
|
recommendGoodsList.add(recommendGoods);
|
|
|
});
|
|
});
|
|
@@ -246,10 +252,24 @@ public class KwpGoodsService {
|
|
|
if (Objects.nonNull(managerInfo)) {
|
|
if (Objects.nonNull(managerInfo)) {
|
|
|
detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
|
|
detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
|
|
|
}
|
|
}
|
|
|
- detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType()))
|
|
|
|
|
- .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit()))
|
|
|
|
|
- .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate()))
|
|
|
|
|
- .setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())))
|
|
|
|
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
|
|
|
|
|
+ DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(), DictTypeEnum.GOODS_STATUS.getType(), DictTypeEnum.ADDRESS_TYPE.getType()));
|
|
|
|
|
+ Map<String, String> productNameMap = new HashMap<>();
|
|
|
|
|
+ Map<String, String> unitMap = new HashMap<>();
|
|
|
|
|
+ Map<String, String> taxRateMap = new HashMap<>();
|
|
|
|
|
+ Map<String, String> goodsStatusMap = new HashMap<>();
|
|
|
|
|
+ Map<String, String> addressMap = new HashMap<>();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
|
|
+ productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
|
|
|
|
|
+ unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
|
|
+ taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
|
|
|
|
|
+ goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
|
|
|
|
|
+ addressMap = dict.get(DictTypeEnum.ADDRESS_TYPE.getType());
|
|
|
|
|
+ }
|
|
|
|
|
+ detail.setGoodsTypeLabel(productNameMap.get(detail.getGoodsType()))
|
|
|
|
|
+ .setUnitLabel(unitMap.get(detail.getUnit()))
|
|
|
|
|
+ .setTaxRateLabel(taxRateMap.get(detail.getTaxRate()))
|
|
|
|
|
+ .setStatusLabel(goodsStatusMap.get(String.valueOf(detail.getStatus())))
|
|
|
.setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
|
|
.setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
|
|
|
//商品图片信息
|
|
//商品图片信息
|
|
|
List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
|
|
List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
|
|
@@ -268,7 +288,7 @@ public class KwpGoodsService {
|
|
|
KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
|
|
KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
|
|
|
AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
|
|
AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
|
|
|
if (Objects.nonNull(addressInfo)) {
|
|
if (Objects.nonNull(addressInfo)) {
|
|
|
- addressInfo.setTypeName(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), addressInfo.getType()));
|
|
|
|
|
|
|
+ addressInfo.setTypeName(addressMap.get(addressInfo.getType()));
|
|
|
}
|
|
}
|
|
|
detail.setImages(images).setPriceRanges(ranges).setAttributes(attributes).setAddressInfo(addressInfo);
|
|
detail.setImages(images).setPriceRanges(ranges).setAttributes(attributes).setAddressInfo(addressInfo);
|
|
|
|
|
|
|
@@ -531,11 +551,23 @@ public class KwpGoodsService {
|
|
|
public List<GoodsListExport> export(ExportStatisticGoodsListParam params) {
|
|
public List<GoodsListExport> export(ExportStatisticGoodsListParam params) {
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(params);
|
|
LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(params);
|
|
|
List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
- List<GoodsList> goodsLists = buildGoodLists(list);
|
|
|
|
|
- if (CollectionUtils.isEmpty(goodsLists)) {
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
- List<GoodsListExport> result = new ArrayList<>();
|
|
|
|
|
|
|
+ return getExportResults(list);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @desc: 获取导出结果
|
|
|
|
|
+ * @author: yzc
|
|
|
|
|
+ * @date: 2023-09-18 15:19
|
|
|
|
|
+ * @Param list:
|
|
|
|
|
+ * @return: java.util.List<com.sckw.product.model.GoodsListExport>
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<GoodsListExport> getExportResults(List<KwpGoods> list) {
|
|
|
|
|
+ List<GoodsList> goodsLists = buildGoodLists(list);
|
|
|
|
|
+ List<GoodsListExport> result = new ArrayList<>(list.size());
|
|
|
AtomicInteger i = new AtomicInteger(1);
|
|
AtomicInteger i = new AtomicInteger(1);
|
|
|
goodsLists.forEach(e -> {
|
|
goodsLists.forEach(e -> {
|
|
|
GoodsListExport export = BeanUtils.copyProperties(e, GoodsListExport.class);
|
|
GoodsListExport export = BeanUtils.copyProperties(e, GoodsListExport.class);
|
|
@@ -604,7 +636,7 @@ public class KwpGoodsService {
|
|
|
* @Param list:
|
|
* @Param list:
|
|
|
* @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
|
|
* @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
|
|
|
*/
|
|
*/
|
|
|
- private List<GoodsList> buildGoodLists(List<KwpGoods> list) {
|
|
|
|
|
|
|
+ public List<GoodsList> buildGoodLists(List<KwpGoods> list) {
|
|
|
List<GoodsList> result = new ArrayList<>(list.size());
|
|
List<GoodsList> result = new ArrayList<>(list.size());
|
|
|
List<Long> goodsIds = new ArrayList<>(list.size());
|
|
List<Long> goodsIds = new ArrayList<>(list.size());
|
|
|
List<Long> supplyEntIds = new ArrayList<>(list.size());
|
|
List<Long> supplyEntIds = new ArrayList<>(list.size());
|
|
@@ -634,16 +666,30 @@ public class KwpGoodsService {
|
|
|
if (CollectionUtils.isNotEmpty(supplyEntIds)) {
|
|
if (CollectionUtils.isNotEmpty(supplyEntIds)) {
|
|
|
entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
}
|
|
}
|
|
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
|
|
|
|
|
+ DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(), DictTypeEnum.GOODS_STATUS.getType()));
|
|
|
|
|
+ Map<String, String> productNameMap, unitMap, taxRateMap, goodsStatusMap;
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
|
|
+ productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
|
|
|
|
|
+ unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
|
|
+ taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
|
|
|
|
|
+ goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ productNameMap = new HashMap<>();
|
|
|
|
|
+ unitMap = new HashMap<>();
|
|
|
|
|
+ taxRateMap = new HashMap<>();
|
|
|
|
|
+ goodsStatusMap = new HashMap<>();
|
|
|
|
|
+ }
|
|
|
Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
list.forEach(e -> {
|
|
list.forEach(e -> {
|
|
|
Long id = e.getId();
|
|
Long id = e.getId();
|
|
|
GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
|
|
GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
|
|
|
UserCacheResDto manager = userMap.get(e.getManager());
|
|
UserCacheResDto manager = userMap.get(e.getManager());
|
|
|
UserCacheResDto createUser = userMap.get(e.getCreateBy());
|
|
UserCacheResDto createUser = userMap.get(e.getCreateBy());
|
|
|
- goodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(goodsList.getStatus())))
|
|
|
|
|
- .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goodsList.getGoodsType()))
|
|
|
|
|
- .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goodsList.getUnit()))
|
|
|
|
|
- .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), goodsList.getTaxRate()))
|
|
|
|
|
|
|
+ goodsList.setStatusLabel(goodsStatusMap.get(String.valueOf(goodsList.getStatus())))
|
|
|
|
|
+ .setGoodsTypeLabel(productNameMap.get(goodsList.getGoodsType()))
|
|
|
|
|
+ .setUnitLabel(unitMap.get(goodsList.getUnit()))
|
|
|
|
|
+ .setTaxRateLabel(taxRateMap.get(goodsList.getTaxRate()))
|
|
|
.setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
|
|
.setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
|
|
|
.setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
|
|
.setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
|
|
|
.setManageName(Objects.nonNull(manager) ? manager.getName() : null)
|
|
.setManageName(Objects.nonNull(manager) ? manager.getName() : null)
|
|
@@ -651,7 +697,8 @@ public class KwpGoodsService {
|
|
|
.setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
|
|
.setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
|
|
|
List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
|
|
List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
|
|
|
if (CollectionUtils.isNotEmpty(priceRanges)) {
|
|
if (CollectionUtils.isNotEmpty(priceRanges)) {
|
|
|
- goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(priceRanges.get(0).getPrice());
|
|
|
|
|
|
|
+ goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice())
|
|
|
|
|
+ .setLowestPrice(priceRanges.get(0).getPrice());
|
|
|
}
|
|
}
|
|
|
result.add(goodsList);
|
|
result.add(goodsList);
|
|
|
});
|
|
});
|
|
@@ -835,13 +882,22 @@ public class KwpGoodsService {
|
|
|
//供应企业信息
|
|
//供应企业信息
|
|
|
List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
-
|
|
|
|
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
|
|
|
|
|
+ DictTypeEnum.UNIT_TYPE.getType()));
|
|
|
|
|
+ Map<String, String> productNameMap, unitMap;
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
|
|
+ productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
|
|
|
|
|
+ unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ productNameMap = new HashMap<>();
|
|
|
|
|
+ unitMap = new HashMap<>();
|
|
|
|
|
+ }
|
|
|
list.forEach(e -> {
|
|
list.forEach(e -> {
|
|
|
BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
|
KwpGoodsAddress address = addressMap.get(e.getId());
|
|
KwpGoodsAddress address = addressMap.get(e.getId());
|
|
|
List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
|
|
List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
|
|
|
- materials.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
|
|
|
|
|
- .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
|
|
|
|
|
|
|
+ materials.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
|
|
|
|
|
+ .setUnitLabel(unitMap.get(e.getUnit()))
|
|
|
.setAddressName(Objects.isNull(address) ? null : address.getCityName())
|
|
.setAddressName(Objects.isNull(address) ? null : address.getCityName())
|
|
|
.setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress())
|
|
.setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress())
|
|
|
.setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
|
|
.setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
|
|
@@ -1012,7 +1068,9 @@ public class KwpGoodsService {
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(KwpGoods::getId, id).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
|
|
|
|
+ wrapper.eq(KwpGoods::getId, id)
|
|
|
|
|
+ .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
|
|
|
|
|
+ .eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
KwpGoods goods = kwpGoodsMapper.selectOne(wrapper);
|
|
KwpGoods goods = kwpGoodsMapper.selectOne(wrapper);
|
|
|
if (Objects.isNull(goods)) {
|
|
if (Objects.isNull(goods)) {
|
|
|
throw new BusinessException("商品不存在或已下架!");
|
|
throw new BusinessException("商品不存在或已下架!");
|