diff --git a/XFFruit.xcodeproj/project.pbxproj b/XFFruit.xcodeproj/project.pbxproj index 53fa1ff7e55d3cce2229fb12b46ef450aef254db..89643440b0f0daa34579270cc30521765f79dce5 100644 --- a/XFFruit.xcodeproj/project.pbxproj +++ b/XFFruit.xcodeproj/project.pbxproj @@ -217,6 +217,8 @@ 871F9F047CDDAC523E4358DC /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86D33EC280C440156ED1B976 /* libPods.a */; }; 8F67988A1DB8CC9400348267 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F6798891DB8CC9400348267 /* WebKit.framework */; }; 8F67988C1DB8CC9E00348267 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F67988B1DB8CC9E00348267 /* WebKit.framework */; }; + 8FD12B531EC4737200845F9B /* ProductStockModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FD12B521EC4737200845F9B /* ProductStockModel.m */; }; + 8FD12B541EC4737200845F9B /* ProductStockModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FD12B521EC4737200845F9B /* ProductStockModel.m */; }; 8FEE25DB1DB60B570099B596 /* GXFFunctionDB.m in Sources */ = {isa = PBXBuildFile; fileRef = 35A1C3571B8F09D2004AC9F7 /* GXFFunctionDB.m */; }; 8FEE25DC1DB60B570099B596 /* IBTTableViewSectionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = C15918251AC062460013B391 /* IBTTableViewSectionInfo.m */; }; 8FEE25DD1DB60B570099B596 /* ICRAppViewControllerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C15918841AC460BC0013B391 /* ICRAppViewControllerManager.m */; }; @@ -1232,6 +1234,8 @@ 86D33EC280C440156ED1B976 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 8F6798891DB8CC9400348267 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/PrivateFrameworks/WebKit.framework; sourceTree = SDKROOT; }; 8F67988B1DB8CC9E00348267 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + 8FD12B511EC4737200845F9B /* ProductStockModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductStockModel.h; sourceTree = "<group>"; }; + 8FD12B521EC4737200845F9B /* ProductStockModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductStockModel.m; sourceTree = "<group>"; }; 8FEE27391DB60B570099B596 /* XFFruit copy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "XFFruit copy.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 8FEE273A1DB60B570099B596 /* XFFruit copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "XFFruit copy-Info.plist"; path = "/Users/Javen/Documents/MyProject/xffruit/XFFruit copy-Info.plist"; sourceTree = "<absolute>"; }; ABFA26041C87D38800274481 /* JavenImages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavenImages.h; sourceTree = "<group>"; }; @@ -2263,6 +2267,8 @@ 72B3C0D21B9D72C600025D81 /* TransportPdtDetail.m */, 7285402E1BDDC69100C7F139 /* Accounttitle.h */, 7285402F1BDDC69100C7F139 /* Accounttitle.m */, + 8FD12B511EC4737200845F9B /* ProductStockModel.h */, + 8FD12B521EC4737200845F9B /* ProductStockModel.m */, ); path = Models; sourceTree = "<group>"; @@ -3681,6 +3687,7 @@ 8FEE26CA1DB60B570099B596 /* ICRModifyPwdViewController.m in Sources */, 8FEE26CB1DB60B570099B596 /* ICRStoreDetailViewController.m in Sources */, 8FEE26CC1DB60B570099B596 /* UIResponder+FirstResponder.m in Sources */, + 8FD12B541EC4737200845F9B /* ProductStockModel.m in Sources */, 8FEE26CD1DB60B570099B596 /* ICRAnnouncementDetailContentView.m in Sources */, 8FEE26CE1DB60B570099B596 /* ResultView.m in Sources */, 8FEE26CF1DB60B570099B596 /* SaleHeaderView.m in Sources */, @@ -4006,6 +4013,7 @@ 30D7494C1ACE340D00C63BA1 /* ICRModifyPwdViewController.m in Sources */, C10214CD1AD8FE200024637E /* ICRStoreDetailViewController.m in Sources */, C142D2B81AC3A155000109A7 /* UIResponder+FirstResponder.m in Sources */, + 8FD12B531EC4737200845F9B /* ProductStockModel.m in Sources */, 30D3C1251ADF6451004AC54E /* ICRAnnouncementDetailContentView.m in Sources */, FEAE16E91B79C9F9009D9E01 /* ResultView.m in Sources */, 728899E51BEF3609003CC41E /* SaleHeaderView.m in Sources */, diff --git a/XFFruit/Controllers/HTTPController/ICRHTTPController.h b/XFFruit/Controllers/HTTPController/ICRHTTPController.h index 7a836e773c0d6bc8fc2dd2f41ae27145f26b65c6..6834fb74ddeb830ae5ea1aa64c2e132ef0e5d0df 100644 --- a/XFFruit/Controllers/HTTPController/ICRHTTPController.h +++ b/XFFruit/Controllers/HTTPController/ICRHTTPController.h @@ -358,6 +358,16 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) { - (void)recievePurchase:(id)data success:(void (^)(id))succ failure:(void (^)(id))fail; +/** + * 获å–采è´å•库å˜åº“å˜ + * + * @param PurchaseUuid PurchaseUuid description + * @param succ succ description + * @param fail fail description + */ +- (void)purchaseStockWithPurchaseUuid:(NSString *)PurchaseUuid + success:(void (^)(id))succ + failure:(void (^)(id))fail; /** * 是å¦wms仓库 diff --git a/XFFruit/Controllers/HTTPController/ICRHTTPController.m b/XFFruit/Controllers/HTTPController/ICRHTTPController.m index cfad012b1506e422feb95b66f064f42c827a9d76..548820887f37063819202952bed26a59db8583cb 100644 --- a/XFFruit/Controllers/HTTPController/ICRHTTPController.m +++ b/XFFruit/Controllers/HTTPController/ICRHTTPController.m @@ -2386,6 +2386,46 @@ acceptTypeJson:YES success:success failure:failure]; } +/** + * 获å–采è´å•库å˜åº“å˜ + * + * @param PurchaseUuid PurchaseUuid description + * @param succ succ description + * @param fail fail description + */ +- (void)purchaseStockWithPurchaseUuid:(NSString *)PurchaseUuid + success:(void (^)(id))succ + failure:(void (^)(id))fail{ + if (!PurchaseUuid) { + if (fail) { + fail( [[self class] ErrorWithMsg:ERROR_PARAMETER code:0] ); + } + return; + } + + void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) { + CLog(@"%@", responseObject); + if (succ) { + succ( responseObject ); + } + }; + void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) { + CLog(@"%@", error); + if (fail) { + fail( error ); + } + }; + + NSString *url = [NSString stringWithFormat:@"%@/mdata/inv/gets/%@",HTTP_REST_API_BASE_URL,PurchaseUuid]; + NSString *encodeUrlStr = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + [self GET:encodeUrlStr + parameters:nil + needToken:NO +acceptTypeJson:YES + success:success + failure:failure]; +} + /** * 是å¦wms仓库 diff --git a/XFFruit/ViewControllers/Transport/Controllers/TransportPurchaseViewController.m b/XFFruit/ViewControllers/Transport/Controllers/TransportPurchaseViewController.m index 48413f92056b8bf41e0c7daf87b7f79cfe2334be..aa9bb1007bfec040245b679f35b8f0f6431b16b4 100644 --- a/XFFruit/ViewControllers/Transport/Controllers/TransportPurchaseViewController.m +++ b/XFFruit/ViewControllers/Transport/Controllers/TransportPurchaseViewController.m @@ -11,8 +11,10 @@ #import "QueryOrder.h" #import "TransportPdtDetail.h" #import "MJRefresh.h" +#import "ProductStockModel.h" #define TopMargin 50 #define TableHeight 50 +NSInteger purchaseStockCheckNumber = 0; @interface TransportPurchaseViewController ()<UITextFieldDelegate,UITableViewDataSource,UITableViewDelegate> { BOOL _isRefresh; @@ -85,6 +87,7 @@ @"userUuid":userUtil.userId, @"billNumberProductLike":billNumberObject, @"fetchParts":@"products", + @"isProductCenter":@(1), @"pageNumber":@(_currentPage), @"pageSize":@(20)}; [[ICRHTTPController sharedController] queryPurchaseWithData:dict success:succ failure:fail]; @@ -262,17 +265,76 @@ } #pragma mark - 按钮确定 - (void)sureClick{ - [self PopViewControllerAnimated:YES]; - if (self.indexArr.count > 0) { - NSMutableArray*arr = [NSMutableArray array]; - for (TransportPdtDetail *detail in self.indexArr) { - detail.purchasePdtDetail = detail.uuid; - detail.uuid = nil; - [arr addObject:detail]; + NSMutableDictionary *dicProduct = [NSMutableDictionary dictionary]; + //把选ä¸çš„商å“和采è´å•对应 + for (PurchaseBill *bill in self.dataArr) { + for (TransportPdtDetail *detail in bill.products) { + if ([self.indexArr containsObject:detail]) { + NSMutableArray *arrProduct = [dicProduct objectForKey:bill.billNumber]; + if (!arrProduct) { + arrProduct = [NSMutableArray array]; + [dicProduct setObject:arrProduct forKey:bill.billNumber]; + } + + [arrProduct addObject:detail]; + } } - self.getProchaseProduct(arr); } + + NSArray *array = dicProduct.allKeys; + __weak TransportPurchaseViewController *weakSelf = self; + [self stockValidWithDic:dicProduct billNumbers:array complete:^{ + [weakSelf PopViewControllerAnimated:YES]; + if (weakSelf.indexArr.count > 0) { + NSMutableArray*arr = [NSMutableArray array]; + for (TransportPdtDetail *detail in weakSelf.indexArr) { + detail.purchasePdtDetail = detail.uuid; + detail.uuid = nil; + [arr addObject:detail]; + } + weakSelf.getProchaseProduct(arr); + } + }]; + + + + + } + +- (void)stockValidWithDic:(NSMutableDictionary *)dic billNumbers:(NSArray *)billNumbers complete:(void (^)(void))complete { + NSString *billNum = billNumbers[purchaseStockCheckNumber]; + NSMutableArray *arrProducts = [dic objectForKey:billNum]; + __weak TransportPurchaseViewController *weakSelf = self; + [HTTP purchaseStockWithPurchaseUuid:billNum success:^(id succ) { + for (NSDictionary *dict in succ[@"data"]) { + ProductStockModel *model = [ProductStockModel new]; + [model setValuesForKeysWithDictionary:dict]; + for (TransportPdtDetail *detail in arrProducts) { + if (detail.qty.floatValue > model.qty.floatValue) { + CLog(@"库å˜ä¸è¶³"); + purchaseStockCheckNumber = 0; + NSString *msg = [NSString stringWithFormat:@"%@库å˜ä¸è¶³ï¼", detail.productName]; + ShowMessage(msg); + return ; + } + } + } + + purchaseStockCheckNumber += 1; + if (purchaseStockCheckNumber == billNumbers.count) { + purchaseStockCheckNumber = 0; + complete(); + }else{ + [weakSelf stockValidWithDic:dic billNumbers:billNumbers complete:complete]; + } + + } failure:^(id fail) { + purchaseStockCheckNumber = 0; + }]; +} + + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. diff --git a/XFFruit/ViewControllers/Transport/Models/ProductStockModel.h b/XFFruit/ViewControllers/Transport/Models/ProductStockModel.h new file mode 100644 index 0000000000000000000000000000000000000000..51e5b1eaa8c810deac1a4bdd5c1700ff9e152c38 --- /dev/null +++ b/XFFruit/ViewControllers/Transport/Models/ProductStockModel.h @@ -0,0 +1,14 @@ +// +// ProductStockModel.h +// XFFruit +// +// Created by Javen on 2017/5/11. +// Copyright © 2017å¹´ Xummer. All rights reserved. +// + +#import "IBTModel.h" + +@interface ProductStockModel : IBTModel +@property (strong, nonatomic) NSString *productCode; +@property (strong, nonatomic) NSNumber *qty; +@end diff --git a/XFFruit/ViewControllers/Transport/Models/ProductStockModel.m b/XFFruit/ViewControllers/Transport/Models/ProductStockModel.m new file mode 100644 index 0000000000000000000000000000000000000000..bb89c290747fc9fad7c9204420d01b519acce775 --- /dev/null +++ b/XFFruit/ViewControllers/Transport/Models/ProductStockModel.m @@ -0,0 +1,13 @@ +// +// ProductStockModel.m +// XFFruit +// +// Created by Javen on 2017/5/11. +// Copyright © 2017å¹´ Xummer. All rights reserved. +// + +#import "ProductStockModel.h" + +@implementation ProductStockModel + +@end diff --git a/XFFruit/ViewControllers/Transport/Views/TransportPurchaseCell.m b/XFFruit/ViewControllers/Transport/Views/TransportPurchaseCell.m index b8ec853719f0495259c81a973210a83e0879ab19..ca6596d1bdd12598c3040d0c54a75510cfbf4959 100644 --- a/XFFruit/ViewControllers/Transport/Views/TransportPurchaseCell.m +++ b/XFFruit/ViewControllers/Transport/Views/TransportPurchaseCell.m @@ -73,9 +73,11 @@ } - (void)setPurchaseBill:(PurchaseBill *)bill selectArr:(NSMutableArray *)selectArr{ + self.bill = bill; self.bgView.height = 92 + bill.products.count * 44; self.secondTable.height = self.bgView.height - 45; - self.titleLabel.text = [NSString stringWithFormat:@"采è´å•:%@",bill.billNumber]; + self.titleLabel.text = [NSString stringWithFormat:@"采è´å•:%@ 创建人:%@", + bill.billNumber, bill.create_operName]; self.secondArr = [NSMutableArray array]; self.selectArr = selectArr; [self.secondArr addObjectsFromArray:bill.products]; @@ -109,7 +111,7 @@ static NSString *cellID = @"TransportPurductCell"; TransportPurductCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; cell.editBtn.enabled = NO; - self.headCell.checkBox.isSelected = self.selectArr.count == self.secondArr.count; + [self checkIsSelectAll]; if (cell == nil) { cell = [[TransportPurductCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID withImageName:@"selected"]; cell.editBtn.hidden = YES; @@ -137,6 +139,17 @@ return cell; } + +- (void)checkIsSelectAll { + BOOL isHasAll = YES; + for (TransportPdtDetail *detail in self.bill.products) { + if (![self.selectArr containsObject:detail]) { + isHasAll = NO; + } + } + + self.headCell.checkBox.isSelected = isHasAll; +} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ // TransportPdtDetail * billProduct = self.secondArr[indexPath.row]; // if ([self isHaveIndexPath:billProduct]) {