Grails groovy boolean返回为null
我有一个函数,它在服务类中返回两个整数和一个布尔值:Grails groovy boolean返回为null,grails,groovy,Grails,Groovy,我有一个函数,它在服务类中返回两个整数和一个布尔值: 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
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]
}
现在,在同一个服务类中,我在一个函数中有另一个语句,它调用这个函数,如下所示:
def (redFlags, yellowFlags, insured) = setEntityRecordBalance(newEntityRecord, params)
println "<><><> Value of insured: " + insured + " " + redFlags + " " + yellowFlags
def (redFlgs, yellowFlgs, isReportable) = setEntityRecordBalanceFlags (newEntityRecord, insured)
def(红旗、黄旗、被保险)=setEntityRecordBalance(newEntityRecord,参数)
println“投保价值:“+投保+”+红旗+“+黄旗”
def(红色、黄色、可报告)=setEntityRecordBalanceFlags(新EntityRecord,投保)
我得到两个整数,但是布尔值返回为空,为什么
这是我得到的错误:
<><><> 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
被保险人价值:空1 0
|错误2014-08-16 18:34:34857[http-bio-8080-exec-10]错误。GrailExceptionResolver-处理请求时发生MissingMethodException:[POST]/FatcaOne_0/customer/saveNewEntityRecord-参数:
地位:
实体管辖权:
国家代码:
出租车号码:
单号:123
实体名称:asdf
一般建议:
第二ID:234
地址:
子状态:
城市镇:
电话:
giin:
方法com.twc.fatcaone.FileImportService.setEntityRecordBalanceFlags()的签名不适用于参数类型:(com.twc.fatcaone.EntityRecord,null)值:[com.twc.fatcaone.EntityRecord:(未保存),…]
可能的解决方案:setEntityRecordBalanceFlags(com.twc.fatcaone.EntityRecord,布尔值)。跟踪如下:
消息:方法com.twc.fatcaone.FileImportService.setEntityRecordBalanceFlags()的签名不适用于参数类型:(com.twc.fatcaone.EntityRecord,null)值:[com.twc.fatcaone.EntityRecord:(未保存),…]
可能的解决方案:setEntityRecordBalanceFlags(com.twc.fatcaone.EntityRecord,布尔值)
直线法
->>1672 |$tt|u在com.twc.fatcaone.FileImportService$$EOn7yRsm中创建新实体记录
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|323 |在com.twc.fatcaone.CustomerController$$EOn7xmG8中保存NewEntityRecord
|198 | doFilter。在grails.plugin.cache.web.filter.PageFragmentCachingFilter中
|63 | grails.plugin.cache.web.filter.AbstractFilter中的doFilter
|1145 |运行工人。在java.util.concurrent.ThreadPoolExecutor中
|615 |在java.util.concurrent.ThreadPoolExecutor$Worker中运行
^744 |运行。在java.lang.Thread中
因为这里
return [redIssues, yellowIssues]
您只返回2个元素,没有第三个布尔值,谢谢。哇,现在感觉不像是智人了。一直盯着代码看太久了,不用担心。有时需要另一双眼睛>_