1 package controllers.services
4 import scala.collection.mutable.ArrayBuffer
5 case class Recursion() {
7 def down(parentPart: Part, partBuffer: ArrayBuffer[PartsListBean], opt: Int):Unit = {
8 for(child <-parentPart.parts) {
9 if(parentPart.partRelation(child.id).delDcId==0) {
10 if(opt!=3 || opt==3 && child.name.startsWith("Unit")) {
11 partBuffer += PartsListBean(parentPart.name, child.name, parentPart.partRelation(child.id).quantity)
13 if(opt==1 || opt==2 && !child.name.startsWith("Part") || opt==3) {
14 Recursion().down(child, partBuffer, opt)
20 def up(childPart: Part, partBuffer: ArrayBuffer[PartsListBean], opt: Int):Unit = {
21 if(childPart.parentParts.size == 0 && opt == 2) {
22 partBuffer += PartsListBean("", childPart.name,0)
24 for(parent <- childPart.parentParts) {
25 if(parent.partRelation(childPart.id).delDcId == 0 ) {
27 partBuffer += PartsListBean(childPart.name, parent.name, parent.partRelation(childPart.id).quantity)
30 Recursion().up(parent, partBuffer, opt)