NewDispatchRequirementModel.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // NewDeliveryRequirementModel.m
  3. // IBOSSHSH
  4. //
  5. // Created by ssl on 2018/1/15.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "NewDispatchRequirementModel.h"
  9. @implementation NewDispatchRequirementModel
  10. #pragma mark - 私有函数
  11. /*!
  12. * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
  13. * 前:模型的属性 后:字典里的属性
  14. */
  15. + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
  16. return @{@"code":@"Code",
  17. @"goodsName":@"GoodsName",
  18. @"receiptType":@"ReceiptType",
  19. @"receiptRemarks":@"ReceiptRemarks",
  20. @"sourceFrom":@"SourceFrom",
  21. @"detailId":@"DetailID",
  22. @"invoiceId":@"InvoiceID",
  23. @"invoiceDetailId":@"InvoiceDetailID",
  24. @"acreage":@"Acreage",
  25. @"onlyCode":@"OnlyCode",
  26. @"outQuantity":@"OutQuantity",
  27. @"circulateType":@"CirculateType",
  28. @"receiptDetailId":@"ReceiptDetailID",
  29. @"finalDeliveryReceiptQuantity":@"FinalDeliveryReceiptQuantity",
  30. @"finalInstallReceiptQuantity":@"FinalInstallationFinishQuantity"
  31. };
  32. }
  33. /*!
  34. * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
  35. * NSDate *time dic[@"t"]是double类型的的秒数
  36. * Dic -> model
  37. */
  38. - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
  39. self.salesDetailType = [[dic objectForKey:@"SalesDetailType"] intValue];
  40. self.decimalPlaces = [[dic objectForKey:@"DecimalPlaces"] intValue];
  41. NSString *str = [NSString stringWithFormat:@"%@%d%@",@"%.",self.decimalPlaces,@"f"];
  42. double receiptQuantity = [[dic objectForKey:@"ReceiptQuantity"]doubleValue];
  43. self.receiptType = @"1";
  44. self.installReceiptType = @"1";
  45. if(receiptQuantity){
  46. self.receiptQuantity = [NSString stringWithFormat:str,receiptQuantity];
  47. }
  48. self.outQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"OutQuantity"]doubleValue]];
  49. self.deliveryQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"DeliveryQuantity"]doubleValue]];
  50. self.finishQuantity = [[dic objectForKey:@"FinishQuantity"]doubleValue];
  51. self.completeReceiptQuantity = [[dic objectForKey:@"CompleteReceiptQuantity"]doubleValue];
  52. self.returnQuantity = [[dic objectForKey:@"ReturnQuantity"]doubleValue];
  53. self.noOutReturnQuantity = [[dic objectForKey:@"NoOutReturnQuantity"]doubleValue];
  54. self.receiptNotInQuantity = [[dic objectForKey:@"ReceiptNotInQuantity"]doubleValue];
  55. self.MNFManufactureQuantity = [[dic objectForKey:@"MNFManufactureQuantity"]doubleValue];
  56. self.sourceFromQuantity = [[dic objectForKey:@"SourceFromQuantity"]doubleValue];
  57. //允许进行回执的量
  58. double tempQuantity;
  59. // if([self.sourceFrom doubleValue] == 1){
  60. // if([self.outQuantity doubleValue] < self.MNFManufactureQuantity){
  61. // tempQuantity = [self.outQuantity doubleValue] -self.receiptNotInQuantity -self.completeReceiptQuantity-self.returnQuantity;
  62. // }else{
  63. // tempQuantity = [self.outQuantity doubleValue] - self.MNFManufactureQuantity-self.receiptNotInQuantity-self.completeReceiptQuantity-self.returnQuantity;
  64. // }
  65. // if(self.salesDetailType == 2){
  66. // tempQuantity = self.sourceFromQuantity - self.completeReceiptQuantity -self.noOutReturnQuantity;
  67. // }
  68. // tempQuantity = tempQuantity < 0 ? 0 :tempQuantity;
  69. // self.maxReceiptQuantity = [self.deliveryQuantity doubleValue] > tempQuantity? tempQuantity:[self.deliveryQuantity doubleValue];
  70. // }else{
  71. // self.maxReceiptQuantity = [self.deliveryQuantity doubleValue] > [self.outQuantity doubleValue]? [self.outQuantity doubleValue]:[self.deliveryQuantity doubleValue];
  72. // }
  73. self.maxReceiptQuantity = [self.deliveryQuantity doubleValue] > [self.outQuantity doubleValue]? [self.outQuantity doubleValue]:[self.deliveryQuantity doubleValue];
  74. //安装
  75. self.installQuantity = [dic objectForKey:@"InstallationQuantity"] == nil?@"0":[NSString stringWithFormat:str,[[dic objectForKey:@"InstallationQuantity"]doubleValue]];
  76. double maxInstallReceiptQuantityValue= [self.installQuantity doubleValue] > [self.outQuantity doubleValue]? [self.outQuantity doubleValue]:[self.installQuantity doubleValue];
  77. self.maxInstallReceiptQuantity = [NSString stringWithFormat:str,maxInstallReceiptQuantityValue];
  78. self.installReceiptQuantity =self.maxInstallReceiptQuantity ;
  79. return YES;
  80. }
  81. @end