WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
ReportManager reportManager = (ReportManager) AppUtil.getApplicationContext().getBean("reportManager");
AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
if (wfTrackProcess != null) {
ReportWorkflowProcessInstance pInstance = reportManager.getReportWorkflowProcessInstance(processInstanceId);
if (pInstance == null) {
pInstance = new ReportWorkflowProcessInstance();
pInstance.setInstanceId(processInstanceId);
//get app
AppDefinition appDef = appService.getAppDefinition(appId, appVersion);
ReportApp reportApp = reportManager.getReportApp(appId, appVersion, appDef.getName());
//get package
ReportWorkflowPackage reportPackage = reportManager.getReportWorkflowPackage(reportApp, wfProcess.getPackageId(), wfProcess.getVersion(), wfProcess.getName());
//get process
ReportWorkflowProcess reportProcess = reportManager.getReportWorkflowProcess(reportPackage, wfProcess.getIdWithoutVersion(), wfProcess.getName());
pInstance.setReportWorkflowProcess(reportProcess);
}
pInstance.setRequester(wfTrackProcess.getRequesterId());
pInstance.setState(wfProcess.getState());
pInstance.setDue(wfTrackProcess.getDue());
pInstance.setStartedTime(wfTrackProcess.getStartedTime());
pInstance.setFinishTime(wfTrackProcess.getFinishTime());
pInstance.setDelay(wfTrackProcess.getDelayInSeconds());
pInstance.setTimeConsumingFromStartedTime(wfTrackProcess.getTimeConsumingFromDateStartedInSeconds());
reportManager.saveReportWorkflowProcessInstance(pInstance);
return reportManager.getReportWorkflowProcessInstance(processInstanceId);
}