|
|
@@ -1,12 +1,13 @@ |
|
|
package com.ruoyi.platform.scheduling; |
|
|
package com.ruoyi.platform.scheduling; |
|
|
|
|
|
|
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
|
|
|
import com.ruoyi.platform.domain.Ray; |
|
|
import com.ruoyi.platform.domain.Ray; |
|
|
import com.ruoyi.platform.domain.RayIns; |
|
|
import com.ruoyi.platform.domain.RayIns; |
|
|
import com.ruoyi.platform.mapper.RayDao; |
|
|
import com.ruoyi.platform.mapper.RayDao; |
|
|
import com.ruoyi.platform.mapper.RayInsDao; |
|
|
import com.ruoyi.platform.mapper.RayInsDao; |
|
|
|
|
|
import com.ruoyi.platform.mapper.ResourceOccupyDao; |
|
|
import com.ruoyi.platform.service.RayInsService; |
|
|
import com.ruoyi.platform.service.RayInsService; |
|
|
import com.ruoyi.platform.service.ResourceOccupyService; |
|
|
import com.ruoyi.platform.service.ResourceOccupyService; |
|
|
|
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
@@ -25,7 +26,8 @@ public class RayInsStatusTask { |
|
|
private RayInsDao rayInsDao; |
|
|
private RayInsDao rayInsDao; |
|
|
@Resource |
|
|
@Resource |
|
|
private RayDao rayDao; |
|
|
private RayDao rayDao; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private ResourceOccupyDao resourceOccupyDao; |
|
|
@Resource |
|
|
@Resource |
|
|
private ResourceOccupyService resourceOccupyService; |
|
|
private ResourceOccupyService resourceOccupyService; |
|
|
|
|
|
|
|
|
@@ -41,13 +43,19 @@ public class RayInsStatusTask { |
|
|
for (RayIns rayIns : rayInsList) { |
|
|
for (RayIns rayIns : rayInsList) { |
|
|
//当原本状态为null或非终止态时才调用argo接口 |
|
|
//当原本状态为null或非终止态时才调用argo接口 |
|
|
try { |
|
|
try { |
|
|
rayIns = rayInsService.queryStatusFromArgo(rayIns); |
|
|
|
|
|
// 扣除积分 |
|
|
|
|
|
if (Constant.Running.equals(rayIns.getStatus())) { |
|
|
|
|
|
resourceOccupyService.deducing(Constant.TaskType_Ray, null, rayIns.getId(), null, null); |
|
|
|
|
|
} else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) |
|
|
|
|
|
|| Constant.Succeeded.equals(rayIns.getStatus())) { |
|
|
|
|
|
resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); |
|
|
|
|
|
|
|
|
Long userId = resourceOccupyDao.getResourceOccupyByTask(Constant.TaskType_Ray, rayIns.getRayId(), rayIns.getId(), null).get(0).getUserId(); |
|
|
|
|
|
if (resourceOccupyDao.getUserCredit(userId) <= 0) { |
|
|
|
|
|
rayIns.setStatus(Constant.Failed); |
|
|
|
|
|
rayInsService.terminateRayIns(rayIns.getId()); |
|
|
|
|
|
} else { |
|
|
|
|
|
rayIns = rayInsService.queryStatusFromArgo(rayIns); |
|
|
|
|
|
// 扣除积分 |
|
|
|
|
|
if (Constant.Running.equals(rayIns.getStatus())) { |
|
|
|
|
|
resourceOccupyService.deducing(Constant.TaskType_Ray, null, rayIns.getId(), null, null); |
|
|
|
|
|
} else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) |
|
|
|
|
|
|| Constant.Succeeded.equals(rayIns.getStatus())) { |
|
|
|
|
|
resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
rayIns.setStatus(Constant.Failed); |
|
|
rayIns.setStatus(Constant.Failed); |
|
|
|