Selaa lähdekoodia

1.修改NPD离线Model Detail Category Id取值。

Pen Li 8 vuotta sitten
vanhempi
commit
4fbde67d1d

+ 43 - 5
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -3068,6 +3068,21 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     return ret;
 }
+
++ (NSString *) categoryIdOfProduct:(NSString *)product_id name:(NSString *)product_name {
+    
+    NSString *sql = nil;
+    if (product_id != nil) {
+        sql = [NSString stringWithFormat:@"select category from product where product_id = '%@';",product_id];
+    } else {
+        sql = [NSString stringWithFormat:@"select category from product where name = '%@';",product_name];
+    }
+    NSString *result_set = [iSalesDB jk_queryText:sql];
+    result_set = [result_set stringByReplacingOccurrencesOfString:@"%" withString:@""];
+    result_set = [result_set stringByReplacingOccurrencesOfString:@"#" withString:@""];
+    return result_set;
+}
+
 +(NSDictionary*) offline_model :(NSMutableDictionary *) params
 {
     
@@ -3082,9 +3097,32 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     NSString* category = [params valueForKey:@"category"];
     
-    
-    if(category==nil)
-        category = [self model_default_category:product_id model_name:model_name];
+    NSString *default_category_id = [self model_default_category:product_id model_name:model_name];
+    if(category==nil) {
+        category = default_category_id;
+    } else {
+        
+        NSArray *arr_0 = [category componentsSeparatedByString:@","];
+        // 参数重有多个category id
+        if (arr_0.count > 1) {
+            NSArray *arr_1 = [[self categoryIdOfProduct:product_id name:model_name] componentsSeparatedByString:@","];
+            
+            // 取交集
+            NSMutableSet *set_0 = [NSMutableSet setWithArray:arr_0];
+            NSMutableSet *set_1 = [NSMutableSet setWithArray:arr_1];
+            [set_0 intersectSet:set_1];
+            
+            if (set_0.count == 1) {
+                category = (NSString *)[set_0 anyObject];
+            } else {
+                if ([set_0 containsObject:default_category_id]) {
+                    category = default_category_id;
+                } else {
+                    category = (NSString *)[set_0 anyObject];
+                }
+            }
+        }
+    }
     
     NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
     
@@ -3095,7 +3133,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     sqlite3 *db = [iSalesDB get_db];
     
-    int count = [iSalesDB get_recordcount:db table:@"product" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
+//    int count = [iSalesDB get_recordcount:db table:@"product" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
     
     
     NSString *sqlQuery = nil;
@@ -3398,7 +3436,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     {
         [ret setValue:@"8" forKey:@"result"];
     }
-    DebugLog(@"count:%d",count);
+//    DebugLog(@"count:%d",count);
     
     
     [iSalesDB close_db:db];

+ 2 - 2
RedAnt ERP Mobile/iSales-GATIT.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcschemes/GATIT Mobile.xcscheme

@@ -15,7 +15,7 @@
             <BuildableReference
                BuildableIdentifier = "primary"
                BlueprintIdentifier = "713F76A51929F4A7006A7305"
-               BuildableName = "GATIT Mobile.app"
+               BuildableName = "Titan.app"
                BlueprintName = "iSales-GATIT"
                ReferencedContainer = "container:iSales-GATIT.xcodeproj">
             </BuildableReference>
@@ -58,7 +58,7 @@
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "713F76A51929F4A7006A7305"
-            BuildableName = "GATIT Mobile.app"
+            BuildableName = "Titan.app"
             BlueprintName = "iSales-GATIT"
             ReferencedContainer = "container:iSales-GATIT.xcodeproj">
          </BuildableReference>