Jelajahi Sumber

1.修改iOS Apex Mobile Result数据库删除固定字段。

Pen Li 7 tahun lalu
induk
melakukan
4022b97c11

+ 3 - 0
Apex Mobile/Apex Mobile/ApexMobileDB.h

@@ -35,4 +35,7 @@
 + (NSArray *)getActionsForFunction:(NSString *)function withUser:(NSString *)user;
 + (NSString *)getDisplayFieldsForFunction:(NSString *)function withUser:(NSString *)user;
 
++ (NSString *)getDisplayFieldsForFunction:(NSString *)function withUser:(NSString *)user limit:(NSUInteger)limit;
++ (void)deleteResultFields;
+
 @end

+ 53 - 0
Apex Mobile/Apex Mobile/ApexMobileDB.m

@@ -296,6 +296,9 @@
         sqlite3_close(db);
 //        int aaa = 0;
     }
+    
+    [self deleteResultFields];
+    
     return YES;
     
     
@@ -637,4 +640,54 @@
     return fields;
 }
 
++ (NSString *)getDisplayFieldsForFunction:(NSString *)function withUser:(NSString *)user limit:(NSUInteger)limit {
+    
+    if (!function || !user) {
+        return @"";
+    }
+    
+    NSString *sql = [NSString stringWithFormat:@"select name from fields_info where function_name='%@' and user='%@' and behavior=%d and show=1 order by priority,aname limit %lu",function, user,BEHAVIOR_RESULT, limit];
+    
+    __block NSString* fields = @"";
+    [self jk_sync_query:sql completion:^(sqlite3_stmt *stmt, long *count) {
+        
+        NSString *name = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(stmt, 0)];
+        fields = [fields stringByAppendingFormat:@"%@,",name];
+        
+        
+    } failure:^(NSString *err_msg) {
+        
+    }];
+    
+    if (fields.length > 0) {
+        fields=[fields substringToIndex: fields.length-1];
+    }
+    return fields;
+}
+
+// 数据库初始化完成之后或数据库更新之后删除
++ (void)deleteResultFields {
+    
+    NSString *key = @"delete_result_fields";
+    BOOL delete = [[NSUserDefaults standardUserDefaults] boolForKey:key];
+    if (!delete) {
+     
+        NSString *booking_sql = @"delete from fields_info where behavior = 1 and function_name = 'Ocean Booking' and name in ('booking_no','shipper','consignee','po_no','f_etd,m_eta','place_of_receipt_uncode','place_of_delivery_uncode');";
+        
+        NSString *bl_sql = @"delete from fields_info where behavior = 1 and function_name = 'Ocean B/L info.' and name in ('last_status_315_code','shipper,consignee','h_bol,etd','eta,po_no','place_of_receipt_un','place_of_delivery_un');";
+        
+        NSString *cn_sql = @"delete from fields_info where behavior = 1 and function_name = 'Container detail' and name in ('shipper','consignee','ctnr','file_no','po_no','etd','eta','fport_of_loading_un','mport_of_discharge_un');";
+        
+        sqlite3 *db = [self get_db];
+        
+        [self execSql:booking_sql db:db];
+        [self execSql:bl_sql db:db];
+        [self execSql:cn_sql db:db];
+        
+        sqlite3_close(db);
+        
+        [[NSUserDefaults standardUserDefaults] setValue:@(YES) forKey:key];
+    }
+}
+
 @end

+ 13 - 6
Apex Mobile/Apex Mobile/CustomizeFieldViewController.m

@@ -37,8 +37,6 @@
     sqlite3 *db =[ApexMobileDB get_db];
     NSString *quary = [NSString stringWithFormat:@"select aname,show from fields_info where function_name='%@' and user='%@' and behavior=%d order by priority,aname",self.function_name, appDelegate.user,self.behavior];
     
-    
-    
     sqlite3_stmt *stmt;
     if (sqlite3_prepare_v2(db, [quary UTF8String], -1, &stmt, nil) == SQLITE_OK) {
           DebugLog(@"sql:%@",quary);
@@ -46,10 +44,19 @@
         {
             NSString *aname = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(stmt, 0)];
             int show = sqlite3_column_int(stmt, 1);
-            if(show==1)
-                [self.displayfields addObject:aname];
-            else
-                [self.hidefields addObject:aname];
+            if (self.forNewResult) {
+                
+                if(show==1 && self.displayfields.count < self.maxDisplayCount)
+                    [self.displayfields addObject:aname];
+                else
+                    [self.hidefields addObject:aname];
+            } else {
+                
+                if(show==1)
+                    [self.displayfields addObject:aname];
+                else
+                    [self.hidefields addObject:aname];
+            }
             
             
         }

+ 7 - 3
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -16,6 +16,7 @@
 #import "KPITableCell.h"
 #import "AMResultViewController.h"
 #import "AMShipMap.h"
+#import "ApexResultViewController.h"
 
 #define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
 #define KPI_CELL_IDENTIFIER @"KPITableCell"
@@ -819,9 +820,12 @@ typedef enum {
                                      @"module_name" : module_name
                                      } mutableCopy];
     
-    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
-    resultVC.params = params;
-    [self.navigationController pushViewController:resultVC animated:YES];
+//    AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
+//    resultVC.params = params;
+//    [self.navigationController pushViewController:resultVC animated:YES];
+    
+    ApexResultViewController *vc = [ApexResultViewController resultViewController:params];
+    [self.navigationController pushViewController:vc animated:YES];
 }
 
 #pragma mark - FlowLayout Delegate

+ 1 - 1
Apex Mobile/Apex Mobile/RANetwork.h

@@ -48,6 +48,6 @@
 + (NSDictionary *)fetchResultParameters:(NSMutableDictionary *)params;
 + (NSDictionary *)saveSearchParameters:(NSString *)paramStr forModule:(NSString *)module withName:(NSString *)name;
 
-+ (NSString *)getDisplayFieldsForFunction:(NSString *)function;
++ (NSString *)getDisplayFieldsForFunction:(NSString *)function limit:(NSUInteger)limit;
 
 @end

+ 4 - 2
Apex Mobile/Apex Mobile/RANetwork.m

@@ -400,6 +400,8 @@
         sqlite3_finalize(stmt);
         sqlite3_finalize(stmt1);
         sqlite3_close(db);
+        
+        [ApexMobileDB deleteResultFields];
         /*
          
          db.setTransactionSuccessful();
@@ -1653,10 +1655,10 @@
     }
 }
 
-+ (NSString *)getDisplayFieldsForFunction:(NSString *)function {
++ (NSString *)getDisplayFieldsForFunction:(NSString *)function limit:(NSUInteger)limit {
 
     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    return [ApexMobileDB getDisplayFieldsForFunction:function withUser:appDelegate.user];
+    return [ApexMobileDB getDisplayFieldsForFunction:function withUser:appDelegate.user limit:limit];
 }
 
 @end

+ 1 - 1
Apex Mobile/Apex Mobile/Result/ApexResultViewController.m

@@ -278,7 +278,7 @@
     ViewController.function_name = module_name;
     ViewController.behavior = BEHAVIOR_RESULT;
     ViewController.forNewResult = YES;
-    ViewController.maxDisplayCount = 3;
+    ViewController.maxDisplayCount = ResultMaxDispalyAdditionCount;
     
     [self.navigationController pushViewController:ViewController animated:YES];
     

+ 2 - 0
Apex Mobile/Apex Mobile/Result/Presenter/ApexResultPresenter.h

@@ -8,6 +8,8 @@
 
 #import <Foundation/Foundation.h>
 
+FOUNDATION_EXTERN const NSUInteger ResultMaxDispalyAdditionCount;
+
 @protocol ApexResultProtocol;
 @class ApexResultBaseModel, ApexResultMenuItem;
 @interface ApexResultPresenter : NSObject

+ 2 - 1
Apex Mobile/Apex Mobile/Result/Presenter/ApexResultPresenter.m

@@ -21,6 +21,7 @@ typedef NS_ENUM(NSUInteger, ApexResultFetchDataType) {
     ApexResultFetchDataTypeLoadMore
 };
 
+const NSUInteger ResultMaxDispalyAdditionCount = 3;
 static const NSInteger detal = 20;
 
 @interface ApexResultPresenter ()
@@ -192,7 +193,7 @@ static const NSInteger detal = 20;
     if (self.dirty) {
         self.dirty = NO;
         NSString *module_name = [self.params objectForKey:@"module_name"];
-        NSString *displayFields = [RANetwork getDisplayFieldsForFunction:module_name];
+        NSString *displayFields = [RANetwork getDisplayFieldsForFunction:module_name limit:ResultMaxDispalyAdditionCount];
         self.displayFields = displayFields;
     }