Просмотр исходного кода

优化Item_image,读取速度加快

Pen Li 9 лет назад
Родитель
Сommit
453008a0b1

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 27 - 6
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -2390,6 +2390,8 @@
     
     [ret setValue:[NSNumber numberWithInt:AP_USER_NOT_AUTH ] forKey:@"result"];
     
+    NSDate *date1 = [NSDate date];
+    
     int count=0;
     int dbresult=sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil);
     if ( dbresult== SQLITE_OK)
@@ -2398,6 +2400,7 @@
         
         while (sqlite3_step(statement) == SQLITE_ROW)
         {
+            NSDate *row_date = [NSDate date];
             
             
             NSMutableDictionary* itemjson = [[NSMutableDictionary alloc] init];
@@ -2415,7 +2418,11 @@
             if(str_price==nil)
             {
 //                NSNumber* price= [self get_model_default_price:appDelegate.contact_id product_id:product_id db:db];
+//                NSDate *price_date = [NSDate date];
                 NSNumber* price = [self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db];
+//                DebugLog(@"price time interval");
+//                [self printTimeIntervalBetween:price_date and:[NSDate date]];
+                
                 if(price==nil)
                     Price=@"No Price.";
                 else
@@ -2452,14 +2459,21 @@
             int stockUom = sqlite3_column_int(statement, 8);
             int _id = sqlite3_column_int(statement, 9);
 
-            
+//            NSDate *subtotal_date = [NSDate date];
             NSDictionary* bsubtotaljson=[self model_subtotal:item_id count:item_count db:db compute_part:true];
+//            DebugLog(@"subtotal_date time interval");
+//            [self printTimeIntervalBetween:subtotal_date and:[NSDate date]];
+            
             double cuft=[bsubtotaljson[@"cuft"] doubleValue];
             double weight=[bsubtotaljson[@"weight"] doubleValue];
             int carton=[bsubtotaljson[@"carton"] intValue];
             
 //            itemjson[@"img_url"]= [self model_category_img:[NSString stringWithFormat:@"%@",[NSNumber numberWithInt:item_id]] model_name:nil db:db];
+//            NSDate *img_date = [NSDate date];
             itemjson[@"img_url"] = [self item_image:[NSString stringWithFormat:@"%@",[NSNumber numberWithInt:item_id]] db:db];
+//            DebugLog(@"img_date time interval");
+//            [self printTimeIntervalBetween:img_date and:[NSDate date]];
+            
             itemjson[@"model"]=nsname;
             itemjson[@"cuft"]=[NSNumber numberWithDouble:cuft];
             itemjson[@"weight"]=[NSNumber numberWithDouble:weight];
@@ -2473,10 +2487,17 @@
             itemjson[@"description"]=[NSString stringWithFormat:@"%@\n%@",nsname,nsdescription ];
             itemjson[@"stockUom"]=[NSNumber numberWithInt:stockUom];
             itemjson[@"note"]=nsline_note;
+            
+//            NSDate *date2 = [NSDate date];
             itemjson[@"combine"]=[self model_bundle:item_id db:db compute_part:false];
+//            DebugLog(@"model_bundle time interval");
+//            [self printTimeIntervalBetween:date2 and:[NSDate date]];
             
             ret[[NSString stringWithFormat:@"item_%d",count]]=itemjson;
             count++;
+            
+//            DebugLog(@"row time interval");
+//            [self printTimeIntervalBetween:row_date and:[NSDate date]];
         }
         
         
@@ -2485,8 +2506,8 @@
     }
     
     
-    
-    
+    DebugLog(@"request cart total time interval");
+    [self printTimeIntervalBetween:date1 and:[NSDate date]];
     
     
     int cart_count=[iSalesDB get_recordcount:db table:@"offline_cart" where:[NSString stringWithFormat:@"so_no='%@'",orderCode]];
@@ -4101,8 +4122,8 @@
     
     NSString *sqlQuery = nil;
 
-    sqlQuery = [NSString stringWithFormat:@"select i.url from product m LEFT join model_image i on m.product_id = i.product_id  where m.item_id=%@ order by i.default_img desc, i._id asc limit 1;",item_id];// select i.url from model m
-    
+//    sqlQuery = [NSString stringWithFormat:@"select i.url from product m LEFT join model_image i on m.product_id = i.product_id  where m.item_id=%@ order by i.default_img desc, i._id asc limit 1;",item_id];// select i.url from model m
+    sqlQuery = [NSString stringWithFormat:@"select i.url from model_image as i where item_id = %@ order by i.default_img desc, i._id asc limit 1;",item_id];
     sqlite3_stmt * statement;
     
     //    int count=0;
@@ -4135,7 +4156,7 @@
     
     
     //  [iSalesDB close_db:db];
-    DebugLog(@"data string: %@",ret );
+//    DebugLog(@"data string: %@",ret );
     
     
     return ret;