|
|
@@ -0,0 +1,74 @@
|
|
|
+package com.sckw.product.service;
|
|
|
+
|
|
|
+import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+import com.sckw.core.utils.BeanUtils;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.product.model.KwpGoods;
|
|
|
+import com.sckw.product.model.KwpGoodsPriceRange;
|
|
|
+import com.sckw.product.model.vo.res.WorkbenchGoodsRes;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @desc: 工作台商品统计相关接口
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-09-13 17:57
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class KwpGoodsStatisticsService {
|
|
|
+
|
|
|
+ private final KwpGoodsService service;
|
|
|
+ private final KwpGoodsPriceRangeService priceRangeService;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 获取工作台商品列表
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-09-13 18:55
|
|
|
+ * @return: java.util.List<com.sckw.product.model.vo.res.WorkbenchGoodsRes>
|
|
|
+ */
|
|
|
+ public List<WorkbenchGoodsRes> workbenchList() {
|
|
|
+ List<KwpGoods> goodsList = service.getWorkbenchList();
|
|
|
+ if (CollectionUtils.isEmpty(goodsList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<WorkbenchGoodsRes> result = new ArrayList<>();
|
|
|
+ List<Long> goodsIds = goodsList.stream().map(KwpGoods::getId).toList();
|
|
|
+ List<Long> supplyEntIds = goodsList.stream().map(KwpGoods::getSupplyEntId).toList();
|
|
|
+ Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = priceRangeService.getByGoodsIds(goodsIds).stream()
|
|
|
+ .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
|
+ //供应企业信息
|
|
|
+ List<EntCacheResDto> entList = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(supplyEntIds)) {
|
|
|
+ entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
+ }
|
|
|
+ Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
+ goodsList.forEach(e -> {
|
|
|
+ WorkbenchGoodsRes goods = BeanUtils.copyProperties(e, WorkbenchGoodsRes.class);
|
|
|
+ goods.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
|
|
|
+ .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
|
|
|
+ .setSupplyFireName(entMap.get(e.getSupplyEntId()));
|
|
|
+ List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(priceRanges)) {
|
|
|
+ goods.setLowestPrice(priceRanges.get(0).getPrice());
|
|
|
+ }
|
|
|
+ result.add(goods);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|