我试图在 View 上显示服务中正在运行的进程的进度。我的 Controller 调用了向第三方发送信息的第一个服务,每次发生这种情况时,我都会通过调用第二个服务进行记录,该服务进行计算以显示请求完成的百分比。
我具有要在第一个服务中更新的值,但不确定如何使用此值更新 View 。在工作完成之前,我不会返回 Controller 。
第一服务
def batch(toCalculate,otherStuffDoneTotal otherData) {
def processPercentage
toCalculate.eachWithIndex(){ data, i ->
def otherMethod = otherMethod1(doStuffHere)
def progress = secondService.progressCalc(otherStuffDone, otherStuffDoneTotal, processPercentage)
}
}
第二服务
def progressCalc(otherStuffDoneTotal, otherStuffDone, processPercentage) {
def retItems
def retObjs = [:]
processPercentage = 100 / otherStuffDoneTotal * otherStuffDone
retItems = [processPercentage: processPercentage]
retObjs.putAll(retItems)
return(retOjbs)
}
如何获取 View 以从第一个服务动态更新值(progress.progressPercentage)
最佳答案
任务并不那么琐碎。
您在这里有3个选择:
关于grails - Grails GSP显示正在计算处理时间的服务变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29011582/