| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- //
- // InventoryDetailModel.m
- // IBOSS
- //
- // Created by 关宏厚 on 2018/12/11.
- // Copyright © 2018 elongtian. All rights reserved.
- //
- #import "InventoryDetailModel.h"
- @implementation InventoryDetailModel
- /*!
- * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
- * 前:模型的属性 后:字典里的属性
- */
- + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
-
- return @{@"code":@"Code",
- @"onlyCode":@"OnlyCode",
- @"wareHouseName":@"WarehouseName",
- @"goodName":@"GoodsName",
- @"specification":@"Specification",
- @"colorNumber":@"ColorNumber",
- @"brandName":@"BrandName",
- @"gradeName":@"GradeName",
- @"positionNumber":@"PositionNumber",
- @"inventoryQuantity":@"InventoryQuantity",
- @"canSaleQuantity":@"CanSaleQuantity",
- @"price":@"jzj",
- @"costPrice":@"EnterPrice",
- @"circulateType":@"CirculateType",
- @"package":@"Package",
- @"occupyQuantity":@"OccupyQuantity",
- @"decimalPlaces":@"DecimalPlaces",
- @"noBookOccupyQuantity":@"NoBookOccupyQuantity",
- @"freezeQuantity":@"FreezeQuantity",
- @"noDeliveryQuantity":@"NoDeliveryQuantity",
- @"noEnterQuantity":@"NoEnterQuantity",
- @"ceaseFlag":@"CeaseFlag",
- @"deliveryQuantity":@"DeliveryQuantity",
- @"seriesName":@"SeriesName",
- @"unitName":@"UnitName",
- @"weight":@"Weight",
- @"varietyName":@"VarietyName",
- @"acreage":@"Acreage",
- @"photo":@"Photo",
- @"expandAttribute":@"ExpandAttribute",
- @"expandAttribute2":@"ExpandAttribute2"
- };
- }
- - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
- if(dic!=nil){
-
- if([[dic allKeys]containsObject:@"CirculateType"]){
- int circulateTypeValue= [[dic objectForKey:@"CirculateType"]intValue];
- if(circulateTypeValue==1){
- int inventoryQuantityValue=[[dic objectForKey:@"InventoryQuantity"]intValue];
- _inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
-
- int canSalesQuantityValue= [[dic objectForKey:@"CanSaleQuantity"]intValue];
- _canSaleQuantity=[NSString stringWithFormat:@"%d",canSalesQuantityValue];
- int occupyQuantityValue=[[dic objectForKey:@"OccupyQuantity"]intValue];
- int freezeQuantityValue=[[dic objectForKey:@"FreezeQuantity"]intValue];
- int noOccupyQuantityValue=[[dic objectForKey:@"NoBookOccupyQuantity"]intValue];
- int noDeliveryQuantityValue=[[dic objectForKey:@"NoDeliveryQuantity"]intValue];
- int noEnterQuantityValue=[[dic objectForKey:@"NoEnterQuantity"]intValue];
- int estimatedShortageQuantityValue=inventoryQuantityValue-occupyQuantityValue-freezeQuantityValue-noOccupyQuantityValue-noDeliveryQuantityValue+noEnterQuantityValue;
- _estimatedShortageQuantity=[NSString stringWithFormat:@"%d",estimatedShortageQuantityValue];
-
- }
- else{
- int decimalPlacesValue=[[dic objectForKey:@"DecimalPlaces"]intValue];
- if(decimalPlacesValue==0){
- int inventoryQuantityValue=[[dic objectForKey:@"InventoryQuantity"]intValue];
- _inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
- int canSalesQuantityValue= [[dic objectForKey:@"CanSaleQuantity"]intValue];
- _canSaleQuantity=[NSString stringWithFormat:@"%d",canSalesQuantityValue];
- int occupyQuantityValue=[[dic objectForKey:@"OccupyQuantity"]intValue];
- int freezeQuantityValue=[[dic objectForKey:@"FreezeQuantity"]intValue];
- int noOccupyQuantityValue=[[dic objectForKey:@"NoBookOccupyQuantity"]intValue];
- int noDeliveryQuantityValue=[[dic objectForKey:@"NoDeliveryQuantity"]intValue];
- int noEnterQuantityValue=[[dic objectForKey:@"NoEnterQuantity"]intValue];
- int estimatedShortageQuantityValue=inventoryQuantityValue-occupyQuantityValue-freezeQuantityValue-noOccupyQuantityValue-noDeliveryQuantityValue+noEnterQuantityValue;
- _estimatedShortageQuantity=[NSString stringWithFormat:@"%d",estimatedShortageQuantityValue];
-
-
- }
- else{
- double inventoryQuantityValue=[[dic objectForKey:@"InventoryQuantity"]doubleValue];
- NSString* decimalFormat = [NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlacesValue,@"f" ];
- _inventoryQuantity=[NSString stringWithFormat:decimalFormat,inventoryQuantityValue];
-
- double canSalesQuantityValue=[[dic objectForKey:@"CanSaleQuantity"]doubleValue];
- _canSaleQuantity=[NSString stringWithFormat:decimalFormat,canSalesQuantityValue];
-
- double occupyQuantityValue=[[dic objectForKey:@"OccupyQuantity"]doubleValue];
- double freezeQuantityValue=[[dic objectForKey:@"FreezeQuantity"]doubleValue];
- double noOccupyQuantityValue=[[dic objectForKey:@"NoBookOccupyQuantity"]doubleValue];
- double noDeliveryQuantityValue=[[dic objectForKey:@"NoDeliveryQuantity"]doubleValue];
- double noEnterQuantityValue=[[dic objectForKey:@"NoEnterQuantity"]doubleValue];
- double estimatedShortageQuantityValue=inventoryQuantityValue-occupyQuantityValue-freezeQuantityValue-noOccupyQuantityValue-noDeliveryQuantityValue+noEnterQuantityValue;
- _estimatedShortageQuantity=[NSString stringWithFormat:decimalFormat,estimatedShortageQuantityValue];
-
-
- }
- }
-
- }
- else{
- int decimalPlacesValue=[[dic objectForKey:@"DecimalPlaces"]intValue];
- if(decimalPlacesValue==0){
- int inventoryQuantityValue=[[dic objectForKey:@"InventoryQuantity"]intValue];
- _inventoryQuantity=[NSString stringWithFormat:@"%d",inventoryQuantityValue];
- int canSalesQuantityValue= [[dic objectForKey:@"CanSaleQuantity"]intValue];
- _canSaleQuantity=[NSString stringWithFormat:@"%d",canSalesQuantityValue];
- int occupyQuantityValue=[[dic objectForKey:@"OccupyQuantity"]intValue];
- int freezeQuantityValue=[[dic objectForKey:@"FreezeQuantity"]intValue];
- int noOccupyQuantityValue=[[dic objectForKey:@"NoBookOccupyQuantity"]intValue];
- int noDeliveryQuantityValue=[[dic objectForKey:@"NoDeliveryQuantity"]intValue];
- int noEnterQuantityValue=[[dic objectForKey:@"NoEnterQuantity"]intValue];
- int estimatedShortageQuantityValue=inventoryQuantityValue-occupyQuantityValue-freezeQuantityValue-noOccupyQuantityValue-noDeliveryQuantityValue+noEnterQuantityValue;
- _estimatedShortageQuantity=[NSString stringWithFormat:@"%d",estimatedShortageQuantityValue];
- }
- else{
- double inventoryQuantityValue=[[dic objectForKey:@"InventoryQuantity"]doubleValue];
- NSString* decimalFormat = [NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlacesValue,@"f" ];
- _inventoryQuantity=[NSString stringWithFormat:decimalFormat,inventoryQuantityValue];
- double canSalesQuantityValue=[[dic objectForKey:@"CanSaleQuantity"]doubleValue];
- _canSaleQuantity=[NSString stringWithFormat:decimalFormat,canSalesQuantityValue];
- double occupyQuantityValue=[[dic objectForKey:@"OccupyQuantity"]doubleValue];
- double freezeQuantityValue=[[dic objectForKey:@"FreezeQuantity"]doubleValue];
- double noOccupyQuantityValue=[[dic objectForKey:@"NoBookOccupyQuantity"]doubleValue];
- double noDeliveryQuantityValue=[[dic objectForKey:@"NoDeliveryQuantity"]doubleValue];
- double noEnterQuantityValue=[[dic objectForKey:@"NoEnterQuantity"]doubleValue];
- double estimatedShortageQuantityValue=inventoryQuantityValue-occupyQuantityValue-freezeQuantityValue-noOccupyQuantityValue-noDeliveryQuantityValue+noEnterQuantityValue;
- _estimatedShortageQuantity=[NSString stringWithFormat:decimalFormat,estimatedShortageQuantityValue];
-
- }
-
-
- }
-
-
- }
- return YES;
- }
- @end
|