RecognizeVATInvoiceResult.cc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/ocr/model/RecognizeVATInvoiceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ocr;
  19. using namespace AlibabaCloud::Ocr::Model;
  20. RecognizeVATInvoiceResult::RecognizeVATInvoiceResult() :
  21. ServiceResult()
  22. {}
  23. RecognizeVATInvoiceResult::RecognizeVATInvoiceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. RecognizeVATInvoiceResult::~RecognizeVATInvoiceResult()
  29. {}
  30. void RecognizeVATInvoiceResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto dataNode = value["Data"];
  37. auto boxNode = dataNode["Box"];
  38. auto allPayerRegisterNoes = boxNode["PayerRegisterNoes"]["PayerRegisterNo"];
  39. for (auto value : allPayerRegisterNoes)
  40. data_.box.payerRegisterNoes.push_back(value.asString());
  41. auto allPayeeAddresses = boxNode["PayeeAddresses"]["PayeeAddress"];
  42. for (auto value : allPayeeAddresses)
  43. data_.box.payeeAddresses.push_back(value.asString());
  44. auto allPayeeBankNames = boxNode["PayeeBankNames"]["PayeeBankName"];
  45. for (auto value : allPayeeBankNames)
  46. data_.box.payeeBankNames.push_back(value.asString());
  47. auto allCheckers = boxNode["Checkers"]["Checker"];
  48. for (auto value : allCheckers)
  49. data_.box.checkers.push_back(value.asString());
  50. auto allTaxAmounts = boxNode["TaxAmounts"]["TaxAmount"];
  51. for (auto value : allTaxAmounts)
  52. data_.box.taxAmounts.push_back(value.asString());
  53. auto allSumAmounts = boxNode["SumAmounts"]["SumAmount"];
  54. for (auto value : allSumAmounts)
  55. data_.box.sumAmounts.push_back(value.asString());
  56. auto allClerks = boxNode["Clerks"]["Clerk"];
  57. for (auto value : allClerks)
  58. data_.box.clerks.push_back(value.asString());
  59. auto allInvoiceNoes = boxNode["InvoiceNoes"]["InvoiceNo"];
  60. for (auto value : allInvoiceNoes)
  61. data_.box.invoiceNoes.push_back(value.asString());
  62. auto allInvoiceDates = boxNode["InvoiceDates"]["InvoiceDate"];
  63. for (auto value : allInvoiceDates)
  64. data_.box.invoiceDates.push_back(value.asString());
  65. auto allInvoiceCodes = boxNode["InvoiceCodes"]["InvoiceCode"];
  66. for (auto value : allInvoiceCodes)
  67. data_.box.invoiceCodes.push_back(value.asString());
  68. auto allInvoiceFakeCodes = boxNode["InvoiceFakeCodes"]["InvoiceFakeCode"];
  69. for (auto value : allInvoiceFakeCodes)
  70. data_.box.invoiceFakeCodes.push_back(value.asString());
  71. auto allPayerNames = boxNode["PayerNames"]["PayerName"];
  72. for (auto value : allPayerNames)
  73. data_.box.payerNames.push_back(value.asString());
  74. auto allPayerBankNames = boxNode["PayerBankNames"]["PayerBankNames"];
  75. for (auto value : allPayerBankNames)
  76. data_.box.payerBankNames.push_back(value.asString());
  77. auto allPayees = boxNode["Payees"]["Payee"];
  78. for (auto value : allPayees)
  79. data_.box.payees.push_back(value.asString());
  80. auto allPayeeNames = boxNode["PayeeNames"]["PayeeName"];
  81. for (auto value : allPayeeNames)
  82. data_.box.payeeNames.push_back(value.asString());
  83. auto allInvoiceAmounts = boxNode["InvoiceAmounts"]["InvoiceAmount"];
  84. for (auto value : allInvoiceAmounts)
  85. data_.box.invoiceAmounts.push_back(value.asString());
  86. auto allWithoutTaxAmounts = boxNode["WithoutTaxAmounts"]["WithoutTaxAmount"];
  87. for (auto value : allWithoutTaxAmounts)
  88. data_.box.withoutTaxAmounts.push_back(value.asString());
  89. auto allPayerAddresses = boxNode["PayerAddresses"]["PayerAddress"];
  90. for (auto value : allPayerAddresses)
  91. data_.box.payerAddresses.push_back(value.asString());
  92. auto allPayeeRegisterNoes = boxNode["PayeeRegisterNoes"]["PayeeRegisterNo"];
  93. for (auto value : allPayeeRegisterNoes)
  94. data_.box.payeeRegisterNoes.push_back(value.asString());
  95. auto contentNode = dataNode["Content"];
  96. if(!contentNode["PayerAddress"].isNull())
  97. data_.content.payerAddress = contentNode["PayerAddress"].asString();
  98. if(!contentNode["PayeeRegisterNo"].isNull())
  99. data_.content.payeeRegisterNo = contentNode["PayeeRegisterNo"].asString();
  100. if(!contentNode["PayeeBankName"].isNull())
  101. data_.content.payeeBankName = contentNode["PayeeBankName"].asString();
  102. if(!contentNode["InvoiceNo"].isNull())
  103. data_.content.invoiceNo = contentNode["InvoiceNo"].asString();
  104. if(!contentNode["PayerRegisterNo"].isNull())
  105. data_.content.payerRegisterNo = contentNode["PayerRegisterNo"].asString();
  106. if(!contentNode["Checker"].isNull())
  107. data_.content.checker = contentNode["Checker"].asString();
  108. if(!contentNode["TaxAmount"].isNull())
  109. data_.content.taxAmount = contentNode["TaxAmount"].asString();
  110. if(!contentNode["InvoiceDate"].isNull())
  111. data_.content.invoiceDate = contentNode["InvoiceDate"].asString();
  112. if(!contentNode["WithoutTaxAmount"].isNull())
  113. data_.content.withoutTaxAmount = contentNode["WithoutTaxAmount"].asString();
  114. if(!contentNode["InvoiceAmount"].isNull())
  115. data_.content.invoiceAmount = contentNode["InvoiceAmount"].asString();
  116. if(!contentNode["AntiFakeCode"].isNull())
  117. data_.content.antiFakeCode = contentNode["AntiFakeCode"].asString();
  118. if(!contentNode["PayerName"].isNull())
  119. data_.content.payerName = contentNode["PayerName"].asString();
  120. if(!contentNode["Payee"].isNull())
  121. data_.content.payee = contentNode["Payee"].asString();
  122. if(!contentNode["SumAmount"].isNull())
  123. data_.content.sumAmount = contentNode["SumAmount"].asString();
  124. if(!contentNode["PayerBankName"].isNull())
  125. data_.content.payerBankName = contentNode["PayerBankName"].asString();
  126. if(!contentNode["Clerk"].isNull())
  127. data_.content.clerk = contentNode["Clerk"].asString();
  128. if(!contentNode["PayeeName"].isNull())
  129. data_.content.payeeName = contentNode["PayeeName"].asString();
  130. if(!contentNode["PayeeAddress"].isNull())
  131. data_.content.payeeAddress = contentNode["PayeeAddress"].asString();
  132. if(!contentNode["InvoiceCode"].isNull())
  133. data_.content.invoiceCode = contentNode["InvoiceCode"].asString();
  134. }
  135. RecognizeVATInvoiceResult::Data RecognizeVATInvoiceResult::getData()const
  136. {
  137. return data_;
  138. }