| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //
- // ProcurementApplyListDetailModel.m
- // IBOSS
- //
- // Created by guan hong hou on 2018/7/24.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "ProcurementApplyListDetailModel.h"
- @implementation ProcurementApplyListDetailModel
- /*!
- * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
- * 前:模型的属性 后:字典里的属性
- */
- + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
-
- return @{@"orderNo":@"OrderNo",
- @"code":@"Code",
- @"onlyCode":@"OnlyCode",
- @"goodsSpecification":@"Specification",
- @"gradeName":@"GradeName",
- @"organizationName":@"OrganizationName",
- @"applyQuantity":@"ApplyQuantity",
- @"approvedQuantity":@"ApprovedQuantity",
- @"applyNo":@"ApplyNo",
- @"contractNo":@"ContractNumber",
- @"brandName":@"BrandName",
- @"kindName":@"KindName",
- @"varietyName":@"VarietyName",
- @"seriesName":@"SeriesName",
- @"unitName":@"UnitName",
- @"decimalPlaces":@"DecimalPlaces",
- @"goodsRemarks":@"GoodsRemarks",
- @"colorNo":@"ColorNo",
- @"toOrderQuantity":@"ToOrderQuantity",
- @"verificationQuantity":@"VerificationQuantity",
- @"applicant":@"ApplicantName",
- @"staffName":@"StaffName",
- @"remarks":@"Remarks",
- @"package":@"Package",
- @"acreage":@"Acreage",
- @"weight":@"Weight",
- @"circulateType":@"CirculateType",
- @"goodsName":@"GoodsName",
- @"box":@"Box",
- @"piece":@"Piece",
- @"M2":@"M2"
- };
- }
- /*!
- * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
- * NSDate *time dic[@"t"]是double类型的的秒数
- */
- /// Dic -> model
- - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
- double acreageValue= [[dic objectForKey:@"Acreage"]doubleValue];
- double weightValue= [[dic objectForKey:@"Weight"]doubleValue];
-
- int circulateTypeValue=[[dic objectForKey:@"CirculateType"]intValue];
- double approvedQuantityValue= [[dic objectForKey:@"ApprovedQuantity"]doubleValue];
- double applyQuantityValue=[[dic objectForKey:@"ApplyQuantity"]doubleValue];
- int decimalPlacesValue=[[dic objectForKey:@"DecimalPlaces"]intValue];
- double toOrderQuantityValue=[[dic objectForKey:@"ToOrderQuantity"]doubleValue];
- double verificationQuantityValue=[[dic objectForKey:@"VerificationQuantity"]doubleValue];
- _orderNo=[dic objectForKey:@"OrderNo"];
- _applyNo=[dic objectForKey:@"ApplyNo"];
- _acreage=[NSString stringWithFormat:@"%.6f",acreageValue];
- _weight=[NSString stringWithFormat:@"%.6f",weightValue];
- if([_orderNo isEqualToString:@"小计"]||[_applyNo isEqualToString:@"小计"]){
- _approvedQuantity=[NSString stringWithFormat:@"%.6f",approvedQuantityValue];
- _applyQuantity=[NSString stringWithFormat:@"%.6f",applyQuantityValue];
- }
- else{
- if(decimalPlacesValue>0){
- NSString *format=[NSString stringWithFormat:@"%@%d%@",@"%.",decimalPlacesValue,@"f" ];
- _approvedQuantity=[NSString stringWithFormat:format,approvedQuantityValue];
- _applyQuantity=[NSString stringWithFormat:format,applyQuantityValue];
- _toOrderQuantity=[NSString stringWithFormat:format,toOrderQuantityValue];
- _verificationQuantity=[NSString stringWithFormat:format,verificationQuantityValue];
-
- }
- }
- if(circulateTypeValue==1){
- if([_package integerValue]>0){
- if(approvedQuantityValue>=0){
- _box = [NSString stringWithFormat:@"%ld",(long)floor(approvedQuantityValue/[_package integerValue])];
-
- }
- else{
- _box=[NSString stringWithFormat:@"%ld",(long)ceil(approvedQuantityValue/[_package integerValue])];
- }
-
- _piece = [NSString stringWithFormat:@"%d",(int)approvedQuantityValue%[_package integerValue]];
-
- }
- }
- else if(circulateTypeValue==2){
- if([_package integerValue]>0&&[_acreage doubleValue]>0){
- long pieces=0;
- if(approvedQuantityValue>=0){
- pieces=ceil(approvedQuantityValue/[_acreage doubleValue]);
- _box=[NSString stringWithFormat:@"%ld",(long)floor(pieces/[_package integerValue])];
- }
- else{
- pieces=floor(approvedQuantityValue/[_acreage doubleValue]);
- _box=[NSString stringWithFormat:@"%ld",(long)ceil(pieces/[_package integerValue])];
-
- }
- _piece=[NSString stringWithFormat:@"%d",(int)pieces%[_package intValue]];
- }
-
- }
- else{
- _box=@"0";
- _piece=@"1";
-
- }
-
- double M2Value;
- if(_acreage!=nil&&_acreage.length>0){
- if(circulateTypeValue==1){
- M2Value=acreageValue*approvedQuantityValue;
- _M2=[NSString stringWithFormat:@"%.6f",M2Value];
- }
- else{
- _M2=_approvedQuantity;
- }
- }
- return YES;
- }
- @end
|