|
@@ -8,17 +8,25 @@ import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoDto;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
+import com.fjhx.item.entity.product.po.ProductClassify;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
|
import com.fjhx.item.mapper.product.ProductInfoMapper;
|
|
|
+import com.fjhx.item.service.product.ProductClassifyService;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.item.util.CodeEnum;
|
|
|
+import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -33,6 +41,9 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, ProductInfo> implements ProductInfoService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductClassifyService productClassifyService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<ProductInfoVo> getPage(ProductInfoSelectDto dto) {
|
|
|
IWrapper<ProductInfo> wrapper = getWrapper();
|
|
@@ -46,6 +57,36 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
new SqlField("pi", ProductInfo::getCustomCode)
|
|
|
);
|
|
|
Page<ProductInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+
|
|
|
+ List<ProductInfoVo> records = page.getRecords();
|
|
|
+
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProductClassify> productClassifyList = productClassifyService.list();
|
|
|
+ Map<Long, ProductClassify> productClassifyMap = productClassifyList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+
|
|
|
+ for (ProductInfoVo record : records) {
|
|
|
+ Long productClassifyId = record.getProductClassifyId();
|
|
|
+ ProductClassify productClassify = productClassifyMap.get(productClassifyId);
|
|
|
+ if (productClassify == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ record.setClassifyName(productClassify.getName());
|
|
|
+
|
|
|
+ List<String> classifyNameGroup = new ArrayList<>();
|
|
|
+
|
|
|
+ while (productClassify != null) {
|
|
|
+ classifyNameGroup.add(0, productClassify.getName());
|
|
|
+ productClassify = productClassifyMap.get(productClassify.getParentId());
|
|
|
+ }
|
|
|
+ record.setClassifyNameGroup(classifyNameGroup);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|