Pereiti prie turinio

reikia pagalbos su algoritmu


Rekomenduojami pranešimai

Niekaip nesugalvoju algoritmo :)

 

Reikia, kad pagal prekės kodą tai pačiai spalvai, pvz L-J301-DK.blue! nuimtų pasikartojančius img ir tiesiog surašytų img pozicijas 1,2,3. Po to kita spalva DK.green! jau paima sekančias tris foto, bet bet sekantiems dydžiams vėl surašo pagal skaičius, t.y. 4,5,6. Esmė - padaryti, kad nesidubliuotų nuotraukos ir kitiems dydžiams būtų nurodytos rodykles (nuotraukų pozicijos). Viską turiu javoje, galiu manipuliuoti duomenimis, tik nesugalvoju pačio algoritmo.

 

Tarkime, yra toks .txt:

 

ID;Attribute(Name:Type:Position);Value(Value:Position);Ref;Quantity;isDefault;Image position;Images;Delete old img
322536;Color:color:0, Dydis:select:1;DK.blue:0, S:1;KL-J301-DK.blue!S;8;0;;https://www.url.lt/KL-J301-DK.blue_Damen-Kleid-DKblue-KL-J301-DKblue.jpg,https://www.url.lt/KL-J301-DK.blueS_Damen-Kleid-Gr-S-DKblue-KL-J301-DKblueS_b2.jpg,https://www.url.lt/KL-J301-DK.blueS_Damen-Kleid-Gr-S-DKblue-KL-J301-DKblueS_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.blue:0, M:1;KL-J301-DK.blue!M;8;0;;https://www.url.lt/KL-J301-DK.blue_Damen-Kleid-DKblue-KL-J301-DKblue.jpg,https://www.url.lt/KL-J301-DK.blue_Damen-Kleid-DKblue-KL-J301-DKblue_b2.jpg,https://www.url.lt/KL-J301-DK.blueM_Damen-Kleid-Gr-M-DKblue-KL-J301-DKblueM_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.blue:0, L:1;KL-J301-DK.blue!L;8;0;;https://www.url.lt/KL-J301-DK.blueL_Damen-Kleid-Gr-L-DKblue-KL-J301-DKblueL.jpg,https://www.url.lt/KL-J301-DK.blue_Damen-Kleid-DKblue-KL-J301-DKblue_b2.jpg,https://www.url.lt/KL-J301-DK.blue_Damen-Kleid-DKblue-KL-J301-DKblue_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.green:0, S:1;KL-J301-DK.green!S;8;0;;https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b2.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.green:0, M:1;KL-J301-DK.green!M;8;0;;https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b2.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.green:0, L:1;KL-J301-DK.green!L;8;0;;https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen.jpg,https://www.url.lt/KL-J301-DK.greenL_Damen-Kleid-Gr-L-DKgreen-KL-J301-DKgreenL_b2.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b3.jpg;1
322536;Color:color:0, Dydis:select:1;grey:0, S:1;KL-J301-grey!S;8;0;;https://www.url.lt/KL-J301-grey_Damen-Kleid-grey-KL-J301-grey.jpg,https://www.url.lt/KL-J301-greyS_Damen-Kleid-Gr-S-grey-KL-J301-greyS_b2.jpg,https://www.url.lt/KL-J301-greyS_Damen-Kleid-Gr-S-grey-KL-J301-greyS_b3.jpg;1
322536;Color:color:0, Dydis:select:1;grey:0, M:1;KL-J301-grey!M;8;0;;https://www.url.lt/KL-J301-grey_Damen-Kleid-grey-KL-J301-grey.jpg,https://www.url.lt/KL-J301-greyM_Damen-Kleid-Gr-M-grey-KL-J301-greyM_b2.jpg,https://www.url.lt/KL-J301-greyM_Damen-Kleid-Gr-M-grey-KL-J301-greyM_b3.jpg;1
322536;Color:color:0, Dydis:select:1;grey:0, L:1;KL-J301-grey!L;8;0;;https://www.url.lt/KL-J301-grey_Damen-Kleid-grey-KL-J301-grey.jpg,https://www.url.lt/KL-J301-grey_Damen-Kleid-grey-KL-J301-grey_b2.jpg,https://www.url.lt/KL-J301-greyL_Damen-Kleid-Gr-L-grey-KL-J301-greyL_b3.jpg;1
322536;Color:color:0, Dydis:select:1;wine:0, S:1;KL-J301-wine!S;8;0;;https://www.url.lt/KL-J301-wine_Damen-Kleid-wine-KL-J301-wine.jpg,https://www.url.lt/KL-J301-wineS_Damen-Kleid-Gr-S-wine-KL-J301-wineS_b2.jpg,https://www.url.lt/KL-J301-wineS_Damen-Kleid-Gr-S-wine-KL-J301-wineS_b3.jpg;1
322536;Color:color:0, Dydis:select:1;wine:0, M:1;KL-J301-wine!M;8;0;;https://www.url.lt/KL-J301-wine_Damen-Kleid-wine-KL-J301-wine.jpg,https://www.url.lt/KL-J301-wineM_Damen-Kleid-Gr-M-wine-KL-J301-wineM_b2.jpg,https://www.url.lt/KL-J301-wineM_Damen-Kleid-Gr-M-wine-KL-J301-wineM_b3.jpg;1
322536;Color:color:0, Dydis:select:1;wine:0, L:1;KL-J301-wine!L;8;0;;https://www.url.lt/KL-J301-wine_Damen-Kleid-wine-KL-J301-wine.jpg,https://www.url.lt/KL-J301-wineL_Damen-Kleid-Gr-L-wine-KL-J301-wineL_b2.jpg,https://www.url.lt/KL-J301-wineL_Damen-Kleid-Gr-L-wine-KL-J301-wineL_b3.jpg;1

 

Reikia tokio rezultato:

 

ID;Attribute(Name:Type:Position);Value(Value:Position);Ref;Quantity;isDefault;Image position;Images;Delete old img
322536;Color:color:0, Dydis:select:1;DK.blue:0, S:1;KL-J301-DK.blue!S;8;0;1,2,3;https://www.url.lt/KL-J301-DK.blue_Damen-Kleid-DKblue-KL-J301-DKblue.jpg,https://www.url.lt/KL-J301-DK.blueS_Damen-Kleid-Gr-S-DKblue-KL-J301-DKblueS_b2.jpg,https://www.url.lt/KL-J301-DK.blueS_Damen-Kleid-Gr-S-DKblue-KL-J301-DKblueS_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.blue:0, M:1;KL-J301-DK.blue!M;8;0;1,2,3;;1
322536;Color:color:0, Dydis:select:1;DK.blue:0, L:1;KL-J301-DK.blue!L;8;0;1,2,3;;1
322536;Color:color:0, Dydis:select:1;DK.green:0, S:1;KL-J301-DK.green!S;8;0;4,5,6;https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b2.jpg,https://www.url.lt/KL-J301-DK.green_Damen-Kleid-DKgreen-KL-J301-DKgreen_b3.jpg;1
322536;Color:color:0, Dydis:select:1;DK.green:0, M:1;KL-J301-DK.green!M;8;0;4,5,6;;1
322536;Color:color:0, Dydis:select:1;DK.green:0, L:1;KL-J301-DK.green!L;8;0;4,5,6;;1
322536;Color:color:0, Dydis:select:1;grey:0, S:1;KL-J301-grey!S;8;0;7,8,9;https://www.url.lt/KL-J301-grey_Damen-Kleid-grey-KL-J301-grey.jpg,https://www.url.lt/KL-J301-greyS_Damen-Kleid-Gr-S-grey-KL-J301-greyS_b2.jpg,https://www.url.lt/KL-J301-greyS_Damen-Kleid-Gr-S-grey-KL-J301-greyS_b3.jpg;1
322536;Color:color:0, Dydis:select:1;grey:0, M:1;KL-J301-grey!M;8;0;7,8,9;;1
322536;Color:color:0, Dydis:select:1;grey:0, L:1;KL-J301-grey!L;8;0;7,8,9;;1
322536;Color:color:0, Dydis:select:1;wine:0, S:1;KL-J301-wine!S;8;0;10,11,12;https://www.url.lt/KL-J301-wine_Damen-Kleid-wine-KL-J301-wine.jpg,https://www.url.lt/KL-J301-wineS_Damen-Kleid-Gr-S-wine-KL-J301-wineS_b2.jpg,https://www.url.lt/KL-J301-wineS_Damen-Kleid-Gr-S-wine-KL-J301-wineS_b3.jpg;1
322536;Color:color:0, Dydis:select:1;wine:0, M:1;KL-J301-wine!M;8;0;10,11,12;;1
322536;Color:color:0, Dydis:select:1;wine:0, L:1;KL-J301-wine!L;8;0;10,11,12;;1

 

Iki šiol pavyko pasiekti:

 

  for(Variation v : variationsList) {
           String fullRefCode = Helpers.variationRefGenerator(v.reference);

           for(Variation v2 : variationsList) {
               if(fullRefCode.equals(Helpers.variationRefGenerator(v2.reference))) {
                   String refCodeColor = Helpers.variationRefGeneratorWithColor(v2.reference);
             visus nuo pradžių pagal spalvos kodą
                   int i = 0; 
                   for(Variation v3: variationsList) {
                if(refCodeColor.equals(Helpers.variationRefGeneratorWithColor(v3.reference))) {
                           i++; 

                           if(i == 1) {
                               if(v3.isOrdered == false) {
                                   v3.isOrdered = true; 
                                   v3.isMain = true; //Pagrindinė variacija

                                   String imgOrder = "";
                                   for(int x = 1; x <= v3.images.size(); x++) {
                                       if(x == v3.images.size()) {
                                           imgOrder = imgOrder + x;
                                       } else {
                                           imgOrder = imgOrder + x + ",";
                                       }  
                                   }
                                   v3.imgOrder = imgOrder;
                               }
                           } else {
                               if(v3.isOrdered == false) {

                                   v3.isOrdered = true;
                                   String imgOrder = "";
                                   for(int x = 1; x <= v3.images.size(); x++) {
                                       if(x == v3.images.size()) {
                                           imgOrder = imgOrder + x;
                                       } else {
                                           imgOrder = imgOrder + x + ",";
                                       }  
                                   }
                                   v3.imgOrder = imgOrder;
                                   v3.images = new ArrayList<String>();
                               }
                           }
                       } else {

                       }
                   }
               }
           }
       }

 

Viskas gerai, išskyrus tai, jog absoliučiai visoms tos pačios prekėms variacijoms nurodomos tos pačios img pozicijos, kaip ir pirmajai variacijai, pvz - 1,2,3. Nors turėtų būti 4,5,6, paskui 7,8,9 ir t.t.

Redagavo Narysx
Nuoroda į pranešimą
Dalintis kituose puslapiuose

Prisijunkite prie diskusijos

Jūs galite rašyti dabar, o registruotis vėliau. Jeigu turite paskyrą, prisijunkite dabar, kad rašytumėte iš savo paskyros.

Svečias
Parašykite atsakymą...

×   Įdėta kaip raiškusis tekstas.   Atkurti formatavimą

  Only 75 emoji are allowed.

×   Nuorodos turinys įdėtas automatiškai.   Rodyti kaip įprastą nuorodą

×   Jūsų anksčiau įrašytas turinys buvo atkurtas.   Išvalyti redaktorių

×   You cannot paste images directly. Upload or insert images from URL.

Įkraunama...
  • Dabar naršo   0 narių

    Nei vienas registruotas narys šiuo metu nežiūri šio puslapio.

×
×
  • Pasirinkite naujai kuriamo turinio tipą...