计算树的高度
This commit is contained in:
parent
1976ac63fd
commit
0ec37f926d
|
|
@ -84,4 +84,11 @@ public class OriginalBomApi extends BaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("computeTreeHeight")
|
||||||
|
@ApiOperation("计算树的高度(测试用)")
|
||||||
|
public ResultVO<Boolean> computeTreeHeight() throws ExecutionException, InterruptedException {
|
||||||
|
return ResultVO.success(originalParentService.compucteLevelNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,28 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算BOM树高度
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public boolean compucteLevelNum() throws ExecutionException, InterruptedException {
|
||||||
|
List<BomNewOriginalParentEntity> list = this.lambdaQuery().le(BomNewOriginalParentEntity::getLevelNum, 0).list();
|
||||||
|
if(CollUtil.isNotEmpty(list)) {
|
||||||
|
for (BomNewOriginalParentEntity bom : list) {
|
||||||
|
List<BomOriginalListVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId());
|
||||||
|
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
|
||||||
|
detailTask.setLevelNum(1);
|
||||||
|
ForkJoinTask<List<BomOriginalListVO>> submit = bomDetailPool.submit(detailTask);
|
||||||
|
submit.get();
|
||||||
|
bom.setLevelNum(detailTask.getLevelNum());
|
||||||
|
|
||||||
|
}
|
||||||
|
this.saveOrUpdateBatch(list);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从plm 转原始BOM
|
* 从plm 转原始BOM
|
||||||
* @param
|
* @param
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -26,6 +27,7 @@ public class OriginalBomDetailTask extends RecursiveTask<List<BomOriginalListVO>
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
public static int levelNum=1;
|
public static int levelNum=1;
|
||||||
|
|
||||||
List<BomOriginalListVO> result = new ArrayList<>();
|
List<BomOriginalListVO> result = new ArrayList<>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue