我有这个函数,它在Service类中返回两个整数和一个布尔值:
def setEntityRecordBalance(EntityRecord entRec, Map params) {
float totalBalance = 0
int redIssues = 0, yellowIssues = 0
boolean insured = false
/* For each account owned by this entity, get its figure in USD and then add to running total. */
if (entRec.accounts == []) {
redIssues++
setCleanFlag(entRec.redIssues, 'No accounts found.')
return [redIssues, yellowIssues]
}
else {
entRec.accounts.each {
def account = AccountRecord.findWhere(uniqueId: it.uniqueId, accountId: it.accountId,
batchID: params.selectedBatch.id)
if (account.amount == null)
totalBalance += 0
else
if (account.currencyType == null || account.currencyType.equalsIgnoreCase('USD'))
totalBalance += account.amount
else
totalBalance += getUSDamount(account)
if (account.insurance != null && (account.insurance.equalsIgnoreCase('Y') || account.insurance.equalsIgnoreCase('YES')))
insured = true
}
}
entRec.balance = totalBalance
return [redIssues, yellowIssues, insured]
}
现在,在同一个Service类中,我在函数中有另一个语句,它调用这个函数:
def (redFlags, yellowFlags, insured) = setEntityRecordBalance(newEntityRecord, params)
println "<><><> Value of insured: " + insured + " " + redFlags + " " + yellowFlags
def (redFlgs, yellowFlgs, isReportable) = setEntityRecordBalanceFlags (newEntityRecord, insured)
我得到了两个整数,但是布尔值返回为null,为什么?
这是我得到的错误:
<><><> Value of insured: null 1 0
| Error 2014-08-16 18:34:34,857 [http-bio-8080-exec-10] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /FatcaOne_0/customer/saveNewEntityRecord - parameters:
status:
entityJurisdiction:
countryCode:
taxIdNumber:
uniqueId: 123
entityName: asdf
generalComments:
secondaryId: 234
address:
subStatus:
cityTown:
telephone:
giin:
No signature of method: com.twc.fatcaone.FileImportService.setEntityRecordBalanceFlags() is applicable for argument types: (com.twc.fatcaone.EntityRecord, null) values: [com.twc.fatcaone.EntityRecord : (unsaved), ...]
Possible solutions: setEntityRecordBalanceFlags(com.twc.fatcaone.EntityRecord, boolean). Stacktrace follows:
Message: No signature of method: com.twc.fatcaone.FileImportService.setEntityRecordBalanceFlags() is applicable for argument types: (com.twc.fatcaone.EntityRecord, null) values: [com.twc.fatcaone.EntityRecord : (unsaved), ...]
Possible solutions: setEntityRecordBalanceFlags(com.twc.fatcaone.EntityRecord, boolean)
Line | Method
->> 1672 | $tt__createNewEntityRecord in com.twc.fatcaone.FileImportService$$EOn7yRsm
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 323 | saveNewEntityRecord in com.twc.fatcaone.CustomerController$$EOn7xmG8
| 198 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . . . . . . . . . in java.lang.Thread
答案 0 :(得分:2)
因为这里
return [redIssues, yellowIssues]
您只返回2个元素,没有第三个布尔值