Browse Source

修复状态错误的问题

zhouhao 8 years ago
parent
commit
23b9f64188

+ 4 - 2
hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/quartz/QuartzJobServiceImpl.java

@@ -169,6 +169,7 @@ public class QuartzJobServiceImpl extends AbstractServiceImpl<QuartzJob, String>
         Assert.notNull(job, "任务不存在");
         String hisId = quartzJobHistoryService.createAndInsertHistory(id);
         String strRes = null;
+        QuartzJobHistory.Status status = FAIL;
         try {
             if (logger.isDebugEnabled())
                 logger.debug("start job [{}]", job.getName());
@@ -199,8 +200,9 @@ public class QuartzJobServiceImpl extends AbstractServiceImpl<QuartzJob, String>
                 if (res instanceof String)
                     strRes = ((String) res);
                 else strRes = JSON.toJSONString(res);
-                quartzJobHistoryService.endHistory(hisId, strRes, SUCCESS);
+                status = SUCCESS;
             } else {
+                status = FAIL;
                 if (result.getException() != null) {
                     strRes = StringUtils.throwable2String(result.getException());
                     logger.error("job failed", result.getException());
@@ -215,7 +217,7 @@ public class QuartzJobServiceImpl extends AbstractServiceImpl<QuartzJob, String>
                 }
             }
         } finally {
-            quartzJobHistoryService.endHistory(hisId, strRes, FAIL);
+            quartzJobHistoryService.endHistory(hisId, strRes, status);
         }
         return strRes;
     }