Commit 404500c5 authored by freecui's avatar freecui

加工单接口bug修改

parent cad79801
...@@ -290,6 +290,7 @@ ...@@ -290,6 +290,7 @@
} }
- (NSString *)httpParameterString { - (NSString *)httpParameterString {
NSString *str = [self stringWithFormatter:@"%Y-%m-%d %H:%M:%S"];
return [self stringWithFormatter:@"%Y-%m-%d %H:%M:%S"]; return [self stringWithFormatter:@"%Y-%m-%d %H:%M:%S"];
} }
- (NSString *)coverStringFromString { - (NSString *)coverStringFromString {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
// Fuctions // Fuctions
- (NSDictionary *)dictForCommit; - (NSDictionary *)dictForCommit;
- (NSMutableDictionary *)mutableDictDateToStringForCommit;//把属性为日期类型的转化为string
- (NSDictionary *)dictForLocalSave; - (NSDictionary *)dictForLocalSave;
- (void)praseFromJsonDict:(NSDictionary *)dict; - (void)praseFromJsonDict:(NSDictionary *)dict;
- (void)praseFromLocalDict:(NSDictionary *)dict; - (void)praseFromLocalDict:(NSDictionary *)dict;
......
...@@ -418,6 +418,48 @@ ...@@ -418,6 +418,48 @@
return mDict; return mDict;
} }
- (NSMutableDictionary *)mutableDictDateToStringForCommit {
unsigned int count;
objc_property_t *properties = class_copyPropertyList([self class], &count);
if (count == 0) {
free(properties);
return nil;
}
NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
NSDictionary *dictSpKeyDict = [[self class] specialKeysAndReplaceKeys];
NSArray *arrSpecialKeys = [dictSpKeyDict allKeys];
NSArray *arrCustomKeys = [[self class] customAcitonKeys];
NSArray *arrLocalKeys = [[self class] localKeys];
for (unsigned int i = 0; i < count; i++) {
objc_property_t property = properties[i];
NSString *key = [NSString stringWithUTF8String:property_getName(property)];
id value = [self valueForKey:key];
if ([value isKindOfClass:[NSDate class]]) {
value = [value httpParameterString];
}
if (value) {
if ([arrCustomKeys containsObject:key] ||
[arrLocalKeys containsObject:key]) {
continue;
} else if ([arrSpecialKeys containsObject:key]) {
[mDict addEntriesFromDictionary:@{dictSpKeyDict[key]: value}];
} else {
[mDict addEntriesFromDictionary:@{key: value}];
}
}
}
free(properties);
return mDict;
}
- (NSDictionary *)dictForLocalSave { - (NSDictionary *)dictForLocalSave {
unsigned int count; unsigned int count;
objc_property_t *properties = class_copyPropertyList([self class], &count); objc_property_t *properties = class_copyPropertyList([self class], &count);
......
...@@ -58,8 +58,8 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -58,8 +58,8 @@ typedef NS_ENUM(NSInteger, cellRow) {
@property (nonatomic, assign) BOOL d_isProduct; @property (nonatomic, assign) BOOL d_isProduct;
@property (nonatomic, strong) NSArray *d_meteilHeaderArr; @property (nonatomic, strong) NSArray *d_meteilHeaderArr;
@property (nonatomic, strong) NSArray *d_productHeaderArr; @property (nonatomic, strong) NSArray *d_productHeaderArr;
@property (nonatomic, strong) NSMutableArray *d_meteilArr; //@property (nonatomic, strong) NSMutableArray *d_meteilArr;
@property (nonatomic, strong) NSMutableArray *d_productArr; //@property (nonatomic, strong) NSMutableArray *d_productArr;
@property (nonatomic, assign) NSInteger d_editOrDelete; @property (nonatomic, assign) NSInteger d_editOrDelete;
...@@ -86,29 +86,29 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -86,29 +86,29 @@ typedef NS_ENUM(NSInteger, cellRow) {
} }
- (void)addNewMaterail: (NSNotification *)aNotification { - (void)addNewMaterail: (NSNotification *)aNotification {
GXFProcessMaterial *material = aNotification.object; GXFProcessMaterial *material = aNotification.object;
if (_d_meteilArr) { if (_d_materialMuArr) {
[_d_meteilArr addObject:material]; [_d_materialMuArr addObject:material];
[self p_refreshData]; [self p_refreshData];
} }
} }
- (void)addNewProduct: (NSNotification *)aNotification { - (void)addNewProduct: (NSNotification *)aNotification {
GXFProcessProduct *product = aNotification.object; GXFProcessProduct *product = aNotification.object;
if (_d_productArr) { if (_d_productMuArr) {
[_d_productArr addObject:product]; [_d_productMuArr addObject:product];
[self p_refreshData]; [self p_refreshData];
} }
} }
- (void)editProduct: (NSNotification *)aNotification { - (void)editProduct: (NSNotification *)aNotification {
GXFProcessProduct *product = aNotification.object; GXFProcessProduct *product = aNotification.object;
if (_d_productArr) { if (_d_productMuArr) {
[_d_productArr replaceObjectAtIndex:_d_editOrDelete withObject:product];//待做:优化为刷新这一条 [_d_productMuArr replaceObjectAtIndex:_d_editOrDelete withObject:product];//待做:优化为刷新这一条
[self p_refreshData]; [self p_refreshData];
} }
} }
- (void)deleteProduct: (NSNotification *)aNotification { - (void)deleteProduct: (NSNotification *)aNotification {
GXFProcessProduct *product = aNotification.object; GXFProcessProduct *product = aNotification.object;
if (_d_productArr) { if (_d_productMuArr) {
[_d_productArr removeObject:product];////待做:优化为刷新这一条 [_d_productMuArr removeObject:product];////待做:优化为刷新这一条
[self p_refreshData]; [self p_refreshData];
} }
} }
...@@ -184,31 +184,31 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -184,31 +184,31 @@ typedef NS_ENUM(NSInteger, cellRow) {
_selectRowArr = [[NSMutableArray alloc]init]; _selectRowArr = [[NSMutableArray alloc]init];
self.d_processBill = [[GXFProcessBill alloc]init]; self.d_processBill = [[GXFProcessBill alloc]init];
if (!self.d_meteilArr) { if (!self.d_materialMuArr) {
self.d_meteilArr = [NSMutableArray array]; self.d_materialMuArr = [NSMutableArray array];
} }
GXFProcessMaterial *processM = [[GXFProcessMaterial alloc]init]; // GXFProcessMaterial *processM = [[GXFProcessMaterial alloc]init];
processM.uuid = @"00"; // processM.uuid = @"00";
processM.productName = @"Material"; // processM.productName = @"Material";
processM.productUuid = @"01"; // processM.productUuid = @"01";
processM.baseQty = @(10); // processM.baseQty = @(10);
processM.instockDate = [NSDate date]; // processM.instockDate = [NSDate date];
[self.d_meteilArr addObject:processM]; // [self.d_materialMuArr addObject:processM];
[self.d_meteilArr addObject:processM]; // [self.d_materialMuArr addObject:processM];
if (!self.d_productArr) { if (!self.d_productMuArr) {
self.d_productArr = [NSMutableArray array]; self.d_productMuArr = [NSMutableArray array];
} }
GXFProcessProduct *processP = [[GXFProcessProduct alloc]init]; // GXFProcessProduct *processP = [[GXFProcessProduct alloc]init];
processP.uuid = @"11"; // processP.uuid = @"11";
processP.productName = @"product"; // processP.productName = @"product";
processP.productUuid = @"12"; // processP.productUuid = @"12";
processP.baseQty = @(10); // processP.baseQty = @(10);
processP.outstockDate = [NSDate date]; // processP.outstockDate = [NSDate date];
[self.d_productArr addObject:processP]; // [self.d_productMuArr addObject:processP];
NSDictionary *dict = [processP dictForCommit];
} }
- (void)initSubViews { - (void)initSubViews {
self.view.backgroundColor = XXFBgColor; self.view.backgroundColor = XXFBgColor;
...@@ -231,9 +231,9 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -231,9 +231,9 @@ typedef NS_ENUM(NSInteger, cellRow) {
return _d_arrLeftTableV.count; return _d_arrLeftTableV.count;
} else { } else {
if (_d_isProduct) { if (_d_isProduct) {
return 2 + _d_productArr.count; return 2 + _d_productMuArr.count;
} }
return 2 + _d_meteilArr.count; return 2 + _d_materialMuArr.count;
} }
} }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
...@@ -394,10 +394,10 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -394,10 +394,10 @@ typedef NS_ENUM(NSInteger, cellRow) {
if (cell == nil) { if (cell == nil) {
if (_d_isProduct) { if (_d_isProduct) {
GXFProcessProduct *processP = (GXFProcessProduct *)_d_productArr[indexPath.row - 2]; GXFProcessProduct *processP = (GXFProcessProduct *)_d_productMuArr[indexPath.row - 2];
cell = [[GXFProcessProductTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID processProduct:processP]; cell = [[GXFProcessProductTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID processProduct:processP];
} else { } else {
GXFProcessMaterial *pm = (GXFProcessMaterial *)_d_meteilArr[indexPath.row - 2]; GXFProcessMaterial *pm = (GXFProcessMaterial *)_d_materialMuArr[indexPath.row - 2];
cell = [[GXFProcessMaterialTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID processMaterial:pm]; cell = [[GXFProcessMaterialTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID processMaterial:pm];
} }
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
...@@ -527,7 +527,7 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -527,7 +527,7 @@ typedef NS_ENUM(NSInteger, cellRow) {
- (void)editClick: (UIButton *)btn{ - (void)editClick: (UIButton *)btn{
if (_d_isProduct) { if (_d_isProduct) {
self.d_editOrDelete = btn.tag - 2; self.d_editOrDelete = btn.tag - 2;
GXFProcessProduct *product = _d_productArr[btn.tag - 2]; GXFProcessProduct *product = _d_productMuArr[btn.tag - 2];
GXFPopNewProductViewController *productVC = [[GXFPopNewProductViewController alloc]initWithProcessProduct:product isEdit: YES]; GXFPopNewProductViewController *productVC = [[GXFPopNewProductViewController alloc]initWithProcessProduct:product isEdit: YES];
[self PushViewController:productVC animated:NO]; [self PushViewController:productVC animated:NO];
} else { } else {
...@@ -558,19 +558,23 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -558,19 +558,23 @@ typedef NS_ENUM(NSInteger, cellRow) {
#pragma GXFBottomViewDelegate #pragma GXFBottomViewDelegate
- (void)bottomViewleftButtonClicked:(UIButton *)leftBtn { - (void)bottomViewleftButtonClicked:(UIButton *)leftBtn {
}
- (void)bottomViewRightButtonClicked:(UIButton *)rightBtn {
CLog(@"ffff"); CLog(@"ffff");
//[IBTCommon checkString:_d_processBill.title] //[IBTCommon checkString:_d_processBill.title]
if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.title]) { // if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.title]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"标题不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; // UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"标题不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show]; // [alert show];
return; // return;
} // }
if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.vendor_name]) { // if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.vendor_name]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择供应商" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; // UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择供应商" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show]; // [alert show];
return; // return;
} // }
if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.warehouse_name]) { if ([IBTCommon checkStringIsNilOrSpance:_d_processBill.warehouse_name]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择加工工厂" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示信息" message:@"请选择加工工厂" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show]; [alert show];
...@@ -580,29 +584,29 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -580,29 +584,29 @@ typedef NS_ENUM(NSInteger, cellRow) {
//保存 //保存
void(^succ)(id) = ^(id data) { void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
// if (data) { // if (data) {
// NSInteger success = [data[@"success"] integerValue]; // NSInteger success = [data[@"success"] integerValue];
// NSString *message = data[@"message"]; // NSString *message = data[@"message"];
// if (success == 1) { // if (success == 1) {
// //成功 // //成功
// if ([state isEqualToString:@"initial"]) {//保存成功 // if ([state isEqualToString:@"initial"]) {//保存成功
// [IBTLoadingView showTips:@"操作成功"]; // [IBTLoadingView showTips:@"操作成功"];
// }else{//提交成功 // }else{//提交成功
// SurveyViewController *svc = [SurveyViewController new]; // SurveyViewController *svc = [SurveyViewController new];
// [self PushViewController:svc animated:YES]; // [self PushViewController:svc animated:YES];
// } // }
// }else{ // }else{
// [IBTLoadingView showTips:message]; // [IBTLoadingView showTips:message];
// } // }
// } // }
}; };
void(^fail)(id) = ^(id data) { void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil]; [IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data]; [IBTLoadingView showTips:data];
}; };
// if(self.survey.uuid.length > 0 && uuidObject == [NSNull null]){ // if(self.survey.uuid.length > 0 && uuidObject == [NSNull null]){
// uuidObject = self.survey.uuid; // uuidObject = self.survey.uuid;
...@@ -614,42 +618,43 @@ typedef NS_ENUM(NSInteger, cellRow) { ...@@ -614,42 +618,43 @@ typedef NS_ENUM(NSInteger, cellRow) {
// version = self.survey.version; // version = self.survey.version;
// } // }
// NSDictionary *material = @{@"uuid":@"",@"productUuid":@"",@"productCode":@"",@"productName":@"",@"instockDate":@"",@"place":@"",@"quality":@"",@"baseQty":@"",@"basePrice":@"",@"total":@"",@"remark":@"",};
// NSDictionary *product = @{@"uuid":@"",@"productUuid":@"",@"productCode":@"",@"productName":@"",@"instockDate":@"",@"place":@"",@"quality":@"",@"baseQty":@"",@"basePrice":@"",@"total":@"",@"remark":@"",};
NSMutableArray *productMuArr = [NSMutableArray array]; NSMutableArray *productMuArr = [NSMutableArray array];
for (int count = 0; count < _d_productArr.count; count ++) { for (int count = 0; count < _d_productMuArr.count; count ++) {
GXFProcessProduct *product = (GXFProcessProduct *)_d_productArr[count]; GXFProcessProduct *product = (GXFProcessProduct *)_d_productMuArr[count];
[productMuArr addObject:[product dictForCommit]]; NSMutableDictionary *dic = [product mutableDictDateToStringForCommit];
// NSDictionary *materialdict = @{@"uuid":@"11",@"productUuid":@"402880e64e287fe2014e28895b8a0032",@"productCode":@"农夫山泉",@"productName":@"dd",@"outstockDate":@"2015-09-05 13:36:16 +0000",@"unit":@"",@"qpc":@"kk",@"qpcStr":@"ll",@"quality":@"9",@"baseQty":@"8",@"remark":@""};
[productMuArr addObject:dic];//productdict];
} }
NSMutableArray *materialMuArr = [NSMutableArray array]; NSMutableArray *materialMuArr = [NSMutableArray array];
for (int count = 0; count < _d_productArr.count; count ++) { for (int count = 0; count < _d_materialMuArr.count; count ++) {
GXFProcessMaterial *material = (GXFProcessMaterial *)_d_materialMuArr[count]; GXFProcessMaterial *material = (GXFProcessMaterial *)_d_materialMuArr[count];
[materialMuArr addObject:[material dictForCommit]]; NSMutableDictionary *dic = [material mutableDictDateToStringForCommit];
// NSDictionary *productdict = @{@"uuid":@"",@"productUuid":@"402880e64e287fe2014e28895b8a0032",@"productCode":@"农夫山泉",@"productName":@"dd",@"outstockDate":@"2015-09-05 13:36:16 +0000",@"place":@"",@"quality":@"",@"baseQty":@"1",@"basePrice":@"2",@"total":@"2",@"remark":@""};
[materialMuArr addObject:dic];//materialdict];
} }
NSDictionary *dict = @{@"uuid":@"",
@"version":@(0), NSDictionary *dict = @{@"uuid":@"",
@"billnumber":@"", @"version":@(0),
@"title":@"title",//[IBTCommon checkString:self.titleStr], @"billnumber":@"",
@"vendor_uuid":_d_processBill.vendor_uuid, @"title":@"title",//[IBTCommon checkString:self.titleStr],
@"vendor_code":_d_processBill.vendor_code, @"vendor_uuid": @"000",//_d_processBill.vendor_uuid,
@"vendor_name":_d_processBill.vendor_name, @"vendor_code": @"111",//_d_processBill.vendor_code,
@"warehouse_uuid":_d_processBill.warehouse_uuid, @"vendor_name": @"ff",//_d_processBill.vendor_name,
@"warehouse_code":_d_processBill.warehouse_code, @"warehouse_uuid":_d_processBill.warehouse_uuid,
@"warehouse_name":_d_processBill.warehouse_name, @"warehouse_code":_d_processBill.warehouse_code,
@"contact":[IBTCommon checkString: _d_processBill.contact], @"warehouse_name":_d_processBill.warehouse_name,
@"contactPhone":[IBTCommon checkString:_d_processBill.contact], @"contact":[IBTCommon checkString: _d_processBill.contact],
@"total":_d_processBill.total, @"contactPhone":[IBTCommon checkString:_d_processBill.contactPhone],
@"remark":[IBTCommon checkString:_d_processBill.remark], @"total":_d_processBill.total,
@"materials":materialMuArr, @"remark":[IBTCommon checkString:_d_processBill.remark],
@"products":productMuArr}; @"materials":materialMuArr,
//[IBTLoadingView showProgressLabel:msg]; @"products":productMuArr};
[[ICRHTTPController sharedController] saveSurveyWithAuthenticode:dict success:succ failure:fail]; //[IBTLoadingView showProgressLabel:msg];
[[ICRHTTPController sharedController] saveSurveyWithAuthenticode:dict success:succ failure:fail];
}
- (void)bottomViewRightButtonClicked:(UIButton *)rightBtn {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment