|
|
|
|
@@ -9,11 +9,13 @@ import com.czg.enums.YesNoEnum;
|
|
|
|
|
import com.czg.exception.CzgException;
|
|
|
|
|
import com.czg.product.dto.ConsInfoDTO;
|
|
|
|
|
import com.czg.product.dto.ProductBriefDTO;
|
|
|
|
|
import com.czg.product.entity.ConsGroup;
|
|
|
|
|
import com.czg.product.entity.ConsGroupRelation;
|
|
|
|
|
import com.czg.product.entity.ConsInfo;
|
|
|
|
|
import com.czg.product.param.ConsSubUnitParam;
|
|
|
|
|
import com.czg.product.service.ConsInfoService;
|
|
|
|
|
import com.czg.sa.StpKit;
|
|
|
|
|
import com.czg.service.product.mapper.ConsGroupMapper;
|
|
|
|
|
import com.czg.service.product.mapper.ConsGroupRelationMapper;
|
|
|
|
|
import com.czg.service.product.mapper.ConsInfoMapper;
|
|
|
|
|
import com.czg.service.product.mapper.ProdConsRelationMapper;
|
|
|
|
|
@@ -28,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 耗材信息
|
|
|
|
|
@@ -41,6 +45,7 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|
|
|
|
|
|
|
|
|
private final ConsGroupRelationMapper consGroupRelationMapper;
|
|
|
|
|
private final ProdConsRelationMapper prodConsRelationMapper;
|
|
|
|
|
private final ConsGroupMapper consGroupMapper;
|
|
|
|
|
|
|
|
|
|
private QueryWrapper buildQueryWrapper(ConsInfoDTO param) {
|
|
|
|
|
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
|
|
|
|
@@ -66,9 +71,13 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|
|
|
|
public Page<ConsInfoDTO> getConsInfoPage(ConsInfoDTO param) {
|
|
|
|
|
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
|
|
|
|
Page<ConsInfoDTO> page = super.pageAs(PageUtil.buildPage(), queryWrapper, ConsInfoDTO.class);
|
|
|
|
|
List<ConsGroup> consGroupList = consGroupMapper.selectListByQuery(QueryWrapper.create().eq(ConsGroup::getShopId, param.getShopId()));
|
|
|
|
|
Map<Long, String> collect = consGroupList.stream().collect(Collectors.toMap(ConsGroup::getId, ConsGroup::getName));
|
|
|
|
|
page.getRecords().parallelStream().forEach(item -> {
|
|
|
|
|
List<ProductBriefDTO> productList = prodConsRelationMapper.getProductListByConId(item.getId());
|
|
|
|
|
item.setProductList(productList);
|
|
|
|
|
String consGroupName = collect.get(item.getConsGroupId());
|
|
|
|
|
item.setConsGroupName(consGroupName);
|
|
|
|
|
});
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
@@ -78,9 +87,13 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|
|
|
|
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
|
|
|
|
queryWrapper.eq(ConsInfo::getStatus, StatusEnum.ENABLED.value());
|
|
|
|
|
List<ConsInfoDTO> list = super.listAs(queryWrapper, ConsInfoDTO.class);
|
|
|
|
|
List<ConsGroup> consGroupList = consGroupMapper.selectListByQuery(QueryWrapper.create().eq(ConsGroup::getShopId, param.getShopId()));
|
|
|
|
|
Map<Long, String> collect = consGroupList.stream().collect(Collectors.toMap(ConsGroup::getId, ConsGroup::getName));
|
|
|
|
|
list.parallelStream().forEach(item -> {
|
|
|
|
|
List<ProductBriefDTO> productList = prodConsRelationMapper.getProductListByConId(item.getId());
|
|
|
|
|
item.setProductList(productList);
|
|
|
|
|
String consGroupName = collect.get(item.getConsGroupId());
|
|
|
|
|
item.setConsGroupName(consGroupName);
|
|
|
|
|
});
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|