Parcourir la source

增加对字符串中字符全为空格的处理,修改orderList中status查询

Pen Li il y a 9 ans
Parent
commit
73b8c1ee77

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


+ 99 - 52
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -2726,6 +2726,17 @@
         text = @"";
     }
     
+    // 将字符全部为' '的字符串干掉
+    int spaceCount = 0;
+    for (int i = 0; i < text.length; i++) {
+        if ([text characterAtIndex:i] == ' ') {
+            spaceCount++;
+        }
+    }
+    if (spaceCount == text.length) {
+        text = @"";
+    }
+    
     return text;
 }
 
@@ -4266,6 +4277,12 @@
 }
 
 + (NSString *)changeDateTime:(NSString *)dateTime Formate:(NSString *)formate withFormate:(NSString *)newFormate {
+    
+    // 把毫秒去掉
+    if ([dateTime containsString:@"."]) {
+        dateTime = [[dateTime componentsSeparatedByString:@"."] firstObject];
+    }
+    
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
     formatter.dateFormat = formate;
     
@@ -4334,7 +4351,7 @@
             if(create_time==nil)
                 create_time= "";
             NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
-            nscreate_time = [self changeDateTimeFormate:nscreate_time];// 与在线统一
+            nscreate_time = [[self changeDateTimeFormate:nscreate_time] stringByAppendingString:@" PST"];// 与在线统一
             
             int status = sqlite3_column_int(statement, 4);
             NSString* nsstatus=@"";
@@ -4666,6 +4683,65 @@
 
 #pragma mark order list
 
++ (NSString *)orderStatus:(int)status erpStatus:(int)erpStatus{
+    NSString *nsstatus = @"";
+    switch (status) {
+        case 0:
+        {
+            nsstatus=@"Temp Order";
+            break;
+        }
+        case 1:
+        {
+            nsstatus=@"Saved Order";
+            break;
+        }
+        case 2: {
+            nsstatus = [self orderStatus:erpStatus erpStatus:-1];
+            break;
+        }
+        case 3:
+        case 15:
+        {
+            nsstatus=@"Cancelled";
+            break;
+        }
+        case 10:
+        {
+            nsstatus=@"Quote Submitted";
+            break;
+        }
+        case 11:
+        {
+            nsstatus=@"Sales Order Submitted";
+            break;
+        }
+        case 12:
+        {
+            nsstatus=@"Processing";
+            break;
+        }
+        case 13:
+        {
+            nsstatus=@"Shipped";
+            break;
+        }
+        case 14:
+        {
+            nsstatus=@"Closed";
+            break;
+        }
+        
+            
+            
+        default:
+            break;
+    }
+    
+    return nsstatus;
+
+}
+
 +(NSData*) offline_orderlist :(NSMutableDictionary *) params
 {
     NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
@@ -4685,7 +4761,13 @@
     if (orderStatus.length > 0) {
         NSArray *order_status_array = [orderStatus componentsSeparatedByString:@","];
         if (order_status_array.count == 1) {
-            where = [where stringByAppendingString:[NSString stringWithFormat:@" and o.status = %@",[order_status_array firstObject]]];
+            int status_value = [[order_status_array firstObject] integerValue];
+            if (status_value <= 1) {
+                where = [where stringByAppendingString:[NSString stringWithFormat:@" and o.status = %d",status_value]];
+            } else {
+                 where = [where stringByAppendingString:[NSString stringWithFormat:@" and o.erpOrderStatus = %d",status_value]];
+            }
+            
         } else if (order_status_array.count > 1) {
             
             for (int i = 0; i < order_status_array.count;i++) {
@@ -4694,14 +4776,23 @@
                 if (i == 0) {
                     condition = @" and (";
                 }
-                where = [where stringByAppendingString:[NSString stringWithFormat:@"%@ o.status = %@",condition,status]];
+//                where = [where stringByAppendingString:[NSString stringWithFormat:@"%@ o.status = %@",condition,status]];
+                
+                int status_value = [status integerValue];
+                if (status_value <= 1) {
+                    where = [where stringByAppendingString:[NSString stringWithFormat:@"%@ o.status = %d",condition,status_value]];
+                } else {
+                    where = [where stringByAppendingString:[NSString stringWithFormat:@" %@ o.erpOrderStatus = %d",condition,status_value]];
+                }
+
+                
             }
             
             where = [where stringByAppendingString:@" )"];
         }
     }
     
-    NSString*     sqlQuery=[NSString stringWithFormat:@"SELECT o._id,o.so_id,o.status,o.sales_rep,o.create_by,decrypt(c.company_name),o.create_time,o.total_price,o.customer_contact from offline_order o left join offline_contact c on o.customer_cid=c.contact_id where %@ order by o.create_time limit %d offset %d" ,where, limit, offset];
+    NSString*     sqlQuery=[NSString stringWithFormat:@"SELECT o._id,o.so_id,o.status,o.sales_rep,o.create_by,decrypt(c.company_name),o.create_time,o.total_price,o.customer_contact,o.erpOrderStatus from offline_order o left join offline_contact c on o.customer_cid=c.contact_id where %@ order by o.create_time desc limit %d offset %d" ,where, limit, offset];
     
     DebugLog(@"order list sql: %@",sqlQuery);
     
@@ -4729,7 +4820,7 @@
             
             
             int status = sqlite3_column_double(statement, 2);
-            
+            int erpStatus = sqlite3_column_double(statement, 9);
             
             char *sales_rep = (char*)sqlite3_column_text(statement, 3);
             if(sales_rep==nil)
@@ -4750,59 +4841,15 @@
             if(create_time==nil)
                 create_time= "";
             NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
+            DebugLog(@"time: %@",nscreate_time);
             nscreate_time = [self changeDateTimeFormate:nscreate_time]; // 与在线统一
             
             double total_price = sqlite3_column_double(statement, 7);
             
             NSString *customer_contact = [self textAtColumn:8 statement:statement];
             
-            NSString* nsstatus=@"";
-            switch (status) {
-                case 0:
-                {
-                    nsstatus=@"Temp Order";
-                    break;
-                }
-                case 1:
-                {
-                    nsstatus=@"Saved Order";
-                    break;
-                }
-                case 10:
-                {
-                    nsstatus=@"Quote Submitted";
-                    break;
-                }
-                case 11:
-                {
-                    nsstatus=@"Sales Order Submitted";
-                    break;
-                }
-                case 12:
-                {
-                    nsstatus=@"Processing";
-                    break;
-                }
-                case 13:
-                {
-                    nsstatus=@"Shipped";
-                    break;
-                }
-                case 14:
-                {
-                    nsstatus=@"Closed";
-                    break;
-                }
-                case 15:
-                {
-                    nsstatus=@"Cancelled";
-                    break;
-                }
-                    
-                    
-                default:
-                    break;
-            }
+            NSString* nsstatus = [self orderStatus:status erpStatus:erpStatus];
+
             //            ": "JH",
             //            "": "$8307.00",
             //            "": "MOB1608050001",