Commit 7cd4ec37 authored by Sandy's avatar Sandy

发运单库存校验

parent 2a743b25
......@@ -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 */,
......
......@@ -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仓库
......
......@@ -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仓库
......
......@@ -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.
......
//
// 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
//
// ProductStockModel.m
// XFFruit
//
// Created by Javen on 2017/5/11.
// Copyright © 2017年 Xummer. All rights reserved.
//
#import "ProductStockModel.h"
@implementation ProductStockModel
@end
......@@ -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]) {
......
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