| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // NewRepairItemModel.m
- // IBOSS
- //
- // Created by apple on 16/1/19.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:新增维修模型
- #import "NewRepairItemModel.h"
- @implementation NewRepairItemModel
- #pragma 私有函数
- /*!
- * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
- * 前:模型的属性 后:字典里的属性
- */
- + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
-
- return @{@"repairId":@"RepairID",
- @"detailId":@"DetailID",
- @"salesDetailId":@"SalesDetailID",
- @"code":@"Code",
- @"onlyCode":@"OnlyCode",
- @"brandName":@"BrandName",
- @"repairQuantity":@"RepairQuantity",
- @"returnQuantity":@"ReturnQuantity",
- @"completeQuantity":@"FinishQuantity",
- @"unitId":@"UnitID",
- @"unitName":@"UnitName",
- @"mm":@"M2",
- @"acreage":@"Acreage",
- @"package":@"Package",
- @"remarks":@"ReceiptRemarks",
- @"sourceFrom":@"SourceFrom"
- };
- }
- /*!
- * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
- * NSDate *time dic[@"t"]是double类型的的秒数
- */
- - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic
- {
- int decimalPlaces = [[dic objectForKey:@"DecimalPlaces"] intValue];
- NSString *str = [NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlaces,@"f"];
-
- self.repairId = [[dic objectForKey:@"RepairID"] stringValue];
-
- self.detailId = [[dic objectForKey:@"DetailID"] stringValue];
- self.salesDetailId = [[dic objectForKey:@"SalesDetailID"] stringValue];
- self.repairQuantity = [dic objectForKey:@"RepairQuantity"] == nil ? @"0":[NSString stringWithFormat:str,[[dic objectForKey:@"RepairQuantity"]doubleValue]];
- self.returnQuantity = [dic objectForKey:@"ReturnQuantity"] == nil?@"0":[NSString stringWithFormat:str,[[dic objectForKey:@"ReturnQuantity"]doubleValue]];
- self.completeQuantity = [dic objectForKey:@"FinishQuantity"] == nil?@"0":[NSString stringWithFormat:str,[[dic objectForKey:@"FinishQuantity"]doubleValue]];
- self.mm = [[dic objectForKey:@"M2"]stringValue];
- self.acreage = [[dic objectForKey:@"Acreage"]stringValue];
- self.package = [[dic objectForKey:@"Package"]stringValue];
- if (self.package == nil|| [self.package isEqualToString:@""] || [self.package isEqualToString:@"0"]) {
- self.box = @"0";
- self.receiptQuantity = @"0";
- self.piece = @"0";
- }
- else{
- double quantity = [self.repairQuantity doubleValue]-[self.completeQuantity doubleValue];
- int result= (int)quantity%[self.package intValue];
- if (quantity == 0.0) {
- self.receiptQuantity = @"0";
- }else{
- self.receiptQuantity = [NSString stringWithFormat:str,quantity];
- }
-
- double box=floor(quantity/([self.package doubleValue]));
- if (box == 0.0) {
- self.box = @"0";
- }else{
- self.box = [NSString stringWithFormat:@"%f",box];
- }
- self.piece = [NSString stringWithFormat:@"%d",result];
-
- }
- return YES;
- }
- @end
|