|
|
@ -112,6 +112,18 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService
|
|
|
|
public List<HwProductInfo> selectHwProductInfoJoinDetailList(HwProductInfo hwProductInfo)
|
|
|
|
public List<HwProductInfo> selectHwProductInfoJoinDetailList(HwProductInfo hwProductInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<HwProductInfo> hwProductInfoJoinDetailList = hwProductInfoMapper.selectHwProductInfoJoinDetailList(hwProductInfo);
|
|
|
|
List<HwProductInfo> hwProductInfoJoinDetailList = hwProductInfoMapper.selectHwProductInfoJoinDetailList(hwProductInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 若配置模式configModal为13,hwProductInfoDetailList应该变为树形结构
|
|
|
|
|
|
|
|
if ("13".equals(hwProductInfo.getConfigModal())) {
|
|
|
|
|
|
|
|
for (HwProductInfo productInfo : hwProductInfoJoinDetailList) {
|
|
|
|
|
|
|
|
if (productInfo.getHwProductInfoDetailList() != null && !productInfo.getHwProductInfoDetailList().isEmpty()) {
|
|
|
|
|
|
|
|
// 将每个产品信息的明细列表转换为树形结构
|
|
|
|
|
|
|
|
List<HwProductInfoDetail> treeStructureList = buildProductInfoDetailTree(productInfo.getHwProductInfoDetailList());
|
|
|
|
|
|
|
|
productInfo.setHwProductInfoDetailList(treeStructureList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return hwProductInfoJoinDetailList;
|
|
|
|
return hwProductInfoJoinDetailList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -123,13 +135,12 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService
|
|
|
|
* @param productInfoDetails 产品明细列表
|
|
|
|
* @param productInfoDetails 产品明细列表
|
|
|
|
* @return 树结构列表
|
|
|
|
* @return 树结构列表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
public List<HwProductInfoDetail> buildProductInfoDetailTree(List<HwProductInfoDetail> productInfoDetails) {
|
|
|
|
public List<HwProductInfoDetail> buildProductInfoDetailTree(List<HwProductInfoDetail> productInfoDetails) {
|
|
|
|
List<HwProductInfoDetail> returnList = new ArrayList<>();
|
|
|
|
List<HwProductInfoDetail> returnList = new ArrayList<>();
|
|
|
|
List<Long> tempList = productInfoDetails.stream().map(HwProductInfoDetail::getProductInfoDetailId).collect(Collectors.toList());
|
|
|
|
List<Long> tempList = productInfoDetails.stream().map(HwProductInfoDetail::getProductInfoDetailId).collect(Collectors.toList());
|
|
|
|
for (HwProductInfoDetail hwProductInfoDetail : productInfoDetails) {
|
|
|
|
for (HwProductInfoDetail hwProductInfoDetail : productInfoDetails) {
|
|
|
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
|
|
|
// 如果是顶级节点(parentId为null、0或者不在当前列表中), 遍历该父节点的所有子节点
|
|
|
|
if (!tempList.contains(hwProductInfoDetail.getParentId())) {
|
|
|
|
if (hwProductInfoDetail.getParentId() == null || hwProductInfoDetail.getParentId() == 0L || !tempList.contains(hwProductInfoDetail.getParentId())) {
|
|
|
|
recursionFn(productInfoDetails, hwProductInfoDetail);
|
|
|
|
recursionFn(productInfoDetails, hwProductInfoDetail);
|
|
|
|
returnList.add(hwProductInfoDetail);
|
|
|
|
returnList.add(hwProductInfoDetail);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -146,7 +157,11 @@ public class HwProductInfoServiceImpl implements IHwProductInfoService
|
|
|
|
private void recursionFn(List<HwProductInfoDetail> list, HwProductInfoDetail t) {
|
|
|
|
private void recursionFn(List<HwProductInfoDetail> list, HwProductInfoDetail t) {
|
|
|
|
// 得到子节点列表
|
|
|
|
// 得到子节点列表
|
|
|
|
List<HwProductInfoDetail> childList = getChildList(list, t);
|
|
|
|
List<HwProductInfoDetail> childList = getChildList(list, t);
|
|
|
|
|
|
|
|
// 设置TreeEntity的children字段
|
|
|
|
t.setChildren(childList);
|
|
|
|
t.setChildren(childList);
|
|
|
|
|
|
|
|
// 设置HwProductInfoDetail的hwProductInfoDetailList字段
|
|
|
|
|
|
|
|
t.setHwProductInfoDetailList(childList);
|
|
|
|
|
|
|
|
|
|
|
|
for (HwProductInfoDetail tChild : childList) {
|
|
|
|
for (HwProductInfoDetail tChild : childList) {
|
|
|
|
if (hasChild(list, tChild)) {
|
|
|
|
if (hasChild(list, tChild)) {
|
|
|
|
recursionFn(list, tChild);
|
|
|
|
recursionFn(list, tChild);
|
|
|
|