|
@@ -98,6 +98,7 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
applyPlan.setNextExecTime(nextDate); |
|
|
applyPlan.setNextExecTime(nextDate); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
applyPlan.setCronExpression(entity.getCronExpression()); |
|
|
return this.updateById(applyPlan); |
|
|
return this.updateById(applyPlan); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -143,6 +144,13 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
applyPlanLog.setJobUuid(yinDaoCallBackBO.getJobUuid()); |
|
|
applyPlanLog.setJobUuid(yinDaoCallBackBO.getJobUuid()); |
|
|
applyPlanLog.setAppId(applyPlan.getAppId()); |
|
|
applyPlanLog.setAppId(applyPlan.getAppId()); |
|
|
applyPlanLog.setOutParam(applyPlan.getOutParam()); |
|
|
applyPlanLog.setOutParam(applyPlan.getOutParam()); |
|
|
|
|
|
if (PlanRunStatus.FINISH.getKey().equals(yinDaoCallBackBO.getStatus())) { |
|
|
|
|
|
// 成功 |
|
|
|
|
|
applyPlanLog.setStatus("0"); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 失败 |
|
|
|
|
|
applyPlanLog.setStatus("1"); |
|
|
|
|
|
} |
|
|
applyPlanLogService.saveOrUpdate(applyPlanLog); |
|
|
applyPlanLogService.saveOrUpdate(applyPlanLog); |
|
|
} |
|
|
} |
|
|
applyPlan.setUpdateBy("系统修改"); |
|
|
applyPlan.setUpdateBy("系统修改"); |
|
@@ -186,12 +194,72 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public boolean appRetry(JobQueryBO jobQueryBO) throws IllegalAccessException { |
|
|
public boolean appRetry(JobQueryBO jobQueryBO) throws IllegalAccessException { |
|
|
BaseDTO baseDTO = YinDaoHttpUtils.appRetry(jobQueryBO); |
|
|
|
|
|
if (baseDTO.getSuccess()) { |
|
|
|
|
|
return baseMapper.appRetry(jobQueryBO.getJobUuid()) > 0; |
|
|
|
|
|
|
|
|
// 状态异常重新创建任务 删除原任务,如果是周期则有任务日志,改变原日志关联id,重新创建的任务绑定新的参数 |
|
|
|
|
|
// 已停止状态重新运行,获取的是旧参数 |
|
|
|
|
|
ApplyPlan plan = applyPlanService.lambdaQuery().eq(ApplyPlan::getTaskUuid, jobQueryBO.getJobUuid()).one(); |
|
|
|
|
|
// 获取应用信息 |
|
|
|
|
|
Apply apply = applyService.lambdaQuery().eq(Apply::getAppId, plan.getAppId()).one(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
// 周期,将日志绑定到新计划 |
|
|
|
|
|
if ("2".equals(plan.getExcType())) { |
|
|
|
|
|
ApplyPlan newApplyPlan = new ApplyPlan(); |
|
|
|
|
|
createApplyPlan(jobQueryBO, plan, apply, newApplyPlan); |
|
|
|
|
|
// 换绑日志 |
|
|
|
|
|
ApplyPlanLog applyPlanLog = new ApplyPlanLog(); |
|
|
|
|
|
applyPlanLog.setPlanId(newApplyPlan.getId()); |
|
|
|
|
|
applyPlanLogService.lambdaUpdate().eq(ApplyPlanLog::getPlanId, plan.getId()).update(applyPlanLog); |
|
|
|
|
|
} else { |
|
|
|
|
|
createApplyPlan(jobQueryBO, plan, apply, new ApplyPlan()); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
throw ex; |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建一个计划 |
|
|
|
|
|
* |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
private boolean createApplyPlan(JobQueryBO jobQueryBO, ApplyPlan plan, Apply apply, ApplyPlan newApplyPlan) { |
|
|
|
|
|
// 创建一个新计划 |
|
|
|
|
|
BeanUtils.copyBeanProp(newApplyPlan, plan); |
|
|
|
|
|
newApplyPlan.setId(null); |
|
|
|
|
|
newApplyPlan.setTaskStatus(PlanRunStatus.AWAIT_CREATE.getKey()); |
|
|
|
|
|
newApplyPlan.setNextExecTime(newApplyPlan.getLastExecTime()); |
|
|
|
|
|
if (jobQueryBO.getNewData()) { |
|
|
|
|
|
if (null != apply.getSupportParam() && apply.getSupportParam() == 1) { |
|
|
|
|
|
newApplyPlan.setSupportParam(apply.getSupportParam()); |
|
|
|
|
|
// 获取参数列表 |
|
|
|
|
|
List<ResourceLibrary> resourceLibraryList = resourceLibraryService.lambdaQuery().eq(ResourceLibrary::getAppId, plan.getAppId()).list(); |
|
|
|
|
|
// 获取参数 每一次执行计划的参数都是独立的 |
|
|
|
|
|
List<ApplyStartBO.RobotParam> paramList = resourceLibraryList.stream() |
|
|
|
|
|
.map(item -> { |
|
|
|
|
|
ApplyStartBO.RobotParam robotParam = new ApplyStartBO.RobotParam(); |
|
|
|
|
|
robotParam.setName(item.getResourceName()); |
|
|
|
|
|
robotParam.setValue(item.getResourceValue()); |
|
|
|
|
|
robotParam.setType(item.getResourceType()); |
|
|
|
|
|
return robotParam; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
if (paramList.isEmpty()) { |
|
|
|
|
|
throw new ServiceException("该应用需要参数,没有检测到参数!"); |
|
|
|
|
|
} else { |
|
|
|
|
|
// json集合转字符串 |
|
|
|
|
|
newApplyPlan.setPlanParams(JSONArray.toJSONString(paramList)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
return false; |
|
|
|
|
|
|
|
|
if (null != apply.getSupportParam() && apply.getSupportParam() == 1) { |
|
|
|
|
|
newApplyPlan.setSupportParam(apply.getSupportParam()); |
|
|
|
|
|
newApplyPlan.setPlanParams(plan.getPlanParams()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// 先删除 在新增 |
|
|
|
|
|
applyPlanService.removeById(plan.getId()); |
|
|
|
|
|
return applyPlanService.save(newApplyPlan); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -239,56 +307,54 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<ListRebotVO> runRebotList = getRunRebot(listRebotVos); |
|
|
|
|
|
if(null == runRebotList){ |
|
|
|
|
|
log.debug("暂无可用空闲机器人"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<String> ids = new ArrayList<>(); |
|
|
List<String> ids = new ArrayList<>(); |
|
|
runRebotList.forEach(rebot -> { |
|
|
|
|
|
applyPlanList.forEach(e -> { |
|
|
|
|
|
log.debug("指定时间执行 执行时间:" + e.getExcTime()); |
|
|
|
|
|
if (ids.contains(e.getId())) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (e.getExcTime().getTime() <= System.currentTimeMillis() && PlanRunStatus.AWAIT_CREATE.getKey().equals(e.getTaskStatus())) { |
|
|
|
|
|
ApplyStartBO applyStartBO = new ApplyStartBO(); |
|
|
|
|
|
applyStartBO.setRobotUuid(e.getAppId()); |
|
|
|
|
|
applyStartBO.setAccountName(rebot.getRobotClientName()); |
|
|
|
|
|
applyStartBO.setManualTime(e.getManualTime()); |
|
|
|
|
|
//high 高 middle 中 low 低 |
|
|
|
|
|
applyStartBO.setPriority("high"); |
|
|
|
|
|
// 如果应用支持参数 |
|
|
|
|
|
if (!Objects.isNull(e.getSupportParam()) && e.getSupportParam() == 1) { |
|
|
|
|
|
if (StringUtils.isNotEmpty(e.getPlanParams())) { |
|
|
|
|
|
applyStartBO.setPlanParams(e.getPlanParams()); |
|
|
|
|
|
List<ApplyStartBO.RobotParam> paramList = JSON.parseArray(e.getPlanParams(), ApplyStartBO.RobotParam.class); |
|
|
|
|
|
applyStartBO.setParams(paramList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
applyPlanList.forEach(e -> { |
|
|
|
|
|
List<ListRebotVO> runRebotList = getRunRebot(listRebotVos, e.getAppId()); |
|
|
|
|
|
if (null == runRebotList) { |
|
|
|
|
|
log.debug("暂无可用空闲机器人"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
ListRebotVO rebot = runRebotList.get(0); |
|
|
|
|
|
log.debug("指定时间执行 执行时间:" + e.getExcTime()); |
|
|
|
|
|
if (ids.contains(e.getId())) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (e.getExcTime().getTime() <= System.currentTimeMillis() && PlanRunStatus.AWAIT_CREATE.getKey().equals(e.getTaskStatus())) { |
|
|
|
|
|
ApplyStartBO applyStartBO = new ApplyStartBO(); |
|
|
|
|
|
applyStartBO.setRobotUuid(e.getAppId()); |
|
|
|
|
|
applyStartBO.setAccountName(rebot.getRobotClientName()); |
|
|
|
|
|
applyStartBO.setManualTime(e.getManualTime()); |
|
|
|
|
|
//high 高 middle 中 low 低 |
|
|
|
|
|
applyStartBO.setPriority("high"); |
|
|
|
|
|
// 如果应用支持参数 |
|
|
|
|
|
if (!Objects.isNull(e.getSupportParam()) && e.getSupportParam() == 1) { |
|
|
|
|
|
if (StringUtils.isNotEmpty(e.getPlanParams())) { |
|
|
|
|
|
applyStartBO.setPlanParams(e.getPlanParams()); |
|
|
|
|
|
List<ApplyStartBO.RobotParam> paramList = JSON.parseArray(e.getPlanParams(), ApplyStartBO.RobotParam.class); |
|
|
|
|
|
applyStartBO.setParams(paramList); |
|
|
} |
|
|
} |
|
|
try { |
|
|
|
|
|
JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); |
|
|
|
|
|
ApplyPlan applyPlan = new ApplyPlan(); |
|
|
|
|
|
applyPlan.setId(e.getId()); |
|
|
|
|
|
applyPlan.setUpdateBy("系统修改"); |
|
|
|
|
|
applyPlan.setUpdateTime(new Date()); |
|
|
|
|
|
applyPlan.setTaskUuid(jobStartVO.getJobUuid()); |
|
|
|
|
|
applyPlan.setTaskStatus(PlanRunStatus.CREATED.getKey()); |
|
|
|
|
|
this.updateById(applyPlan); |
|
|
|
|
|
Rebot updateRebot = new Rebot(); |
|
|
|
|
|
updateRebot.setUpdateBy("系统修改"); |
|
|
|
|
|
updateRebot.setUpdateTime(new Date()); |
|
|
|
|
|
updateRebot.setStatus(RebotStatus.RUNNING.getKey()); |
|
|
|
|
|
if (rebotService.lambdaUpdate().eq(Rebot::getRobotClientName, rebot.getRobotClientName()).update(updateRebot)) { |
|
|
|
|
|
log.debug("applyPlanList:" + applyPlanList.size()); |
|
|
|
|
|
ids.add(e.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (IllegalAccessException ex) { |
|
|
|
|
|
throw new RuntimeException(ex); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); |
|
|
|
|
|
ApplyPlan applyPlan = new ApplyPlan(); |
|
|
|
|
|
applyPlan.setId(e.getId()); |
|
|
|
|
|
applyPlan.setUpdateBy("系统修改"); |
|
|
|
|
|
applyPlan.setUpdateTime(new Date()); |
|
|
|
|
|
applyPlan.setTaskUuid(jobStartVO.getJobUuid()); |
|
|
|
|
|
applyPlan.setTaskStatus(PlanRunStatus.CREATED.getKey()); |
|
|
|
|
|
this.updateById(applyPlan); |
|
|
|
|
|
Rebot updateRebot = new Rebot(); |
|
|
|
|
|
updateRebot.setUpdateBy("系统修改"); |
|
|
|
|
|
updateRebot.setUpdateTime(new Date()); |
|
|
|
|
|
updateRebot.setStatus(RebotStatus.RUNNING.getKey()); |
|
|
|
|
|
if (rebotService.lambdaUpdate().eq(Rebot::getRobotClientName, rebot.getRobotClientName()).update(updateRebot)) { |
|
|
|
|
|
log.debug("applyPlanList:" + applyPlanList.size()); |
|
|
|
|
|
ids.add(e.getId()); |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (IllegalAccessException ex) { |
|
|
|
|
|
throw new RuntimeException(ex); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} catch (InterruptedException e) { |
|
|
} catch (InterruptedException e) { |
|
@@ -348,17 +414,19 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<ListRebotVO> runRebotList = getRunRebot(listRebotVos); |
|
|
|
|
|
if(null == runRebotList){ |
|
|
|
|
|
log.debug("暂无可用空闲机器人"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<String> ids = new ArrayList<>(); |
|
|
List<String> ids = new ArrayList<>(); |
|
|
execApplyPlan.forEach(e -> { |
|
|
execApplyPlan.forEach(e -> { |
|
|
if (listRebotVos.isEmpty()) { |
|
|
if (listRebotVos.isEmpty()) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<ListRebotVO> runRebotList = getRunRebot(listRebotVos, e.getAppId()); |
|
|
|
|
|
if (null == runRebotList) { |
|
|
|
|
|
log.debug("暂无可用空闲机器人"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ListRebotVO rebot = runRebotList.get(0); |
|
|
ListRebotVO rebot = runRebotList.get(0); |
|
|
log.debug("机器人表达式执行调度日志" + rebot.getRobotClientName() + "调度" + e.getAppName() + "应用,排除的应用id为" + ids.toString()); |
|
|
log.debug("机器人表达式执行调度日志" + rebot.getRobotClientName() + "调度" + e.getAppName() + "应用,排除的应用id为" + ids.toString()); |
|
|
if (ids.contains(e.getId())) { |
|
|
if (ids.contains(e.getId())) { |
|
@@ -540,6 +608,13 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
applyPlanLog.setJobUuid(jobQueryVO.getJobUuid()); |
|
|
applyPlanLog.setJobUuid(jobQueryVO.getJobUuid()); |
|
|
applyPlanLog.setAppId(applyPlan.getAppId()); |
|
|
applyPlanLog.setAppId(applyPlan.getAppId()); |
|
|
applyPlanLog.setOutParam(updateApplyPlan.getOutParam()); |
|
|
applyPlanLog.setOutParam(updateApplyPlan.getOutParam()); |
|
|
|
|
|
if (PlanRunStatus.FINISH.getKey().equals(jobQueryVO.getStatus())) { |
|
|
|
|
|
// 成功 |
|
|
|
|
|
applyPlanLog.setStatus("0"); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 失败 |
|
|
|
|
|
applyPlanLog.setStatus("1"); |
|
|
|
|
|
} |
|
|
applyPlanLogService.saveOrUpdate(applyPlanLog); |
|
|
applyPlanLogService.saveOrUpdate(applyPlanLog); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -607,12 +682,6 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<ListRebotVO> runRebotList = getRunRebot(listRebotVos); |
|
|
|
|
|
if(null == runRebotList){ |
|
|
|
|
|
log.debug("暂无可用空闲机器人"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取每个部门优先级最高的计划 |
|
|
// 获取每个部门优先级最高的计划 |
|
|
List<ApplyPlan> applyPlans = new ArrayList<>(); |
|
|
List<ApplyPlan> applyPlans = new ArrayList<>(); |
|
|
applyPlanMap.forEach((k, v) -> { |
|
|
applyPlanMap.forEach((k, v) -> { |
|
@@ -625,20 +694,22 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
} |
|
|
} |
|
|
applyPlans.sort((Comparator.comparingInt(ApplyPlan::getPriority))); |
|
|
applyPlans.sort((Comparator.comparingInt(ApplyPlan::getPriority))); |
|
|
|
|
|
|
|
|
for (ListRebotVO listRebotVO : runRebotList) { |
|
|
|
|
|
if (applyPlans.isEmpty()) { |
|
|
|
|
|
log.debug("没有等待执行的计划!"); |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ApplyPlan runApplyPlan : applyPlans) { |
|
|
|
|
|
List<ListRebotVO> runRebotList = getRunRebot(listRebotVos, runApplyPlan.getAppId()); |
|
|
|
|
|
if (null == runRebotList) { |
|
|
|
|
|
log.debug("暂无可用空闲机器人"); |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
applyPlan = applyPlans.get(0); |
|
|
|
|
|
|
|
|
|
|
|
applyStartBO = new ApplyStartBO(); |
|
|
applyStartBO = new ApplyStartBO(); |
|
|
applyStartBO.setRobotUuid(applyPlan.getAppId()); |
|
|
|
|
|
|
|
|
applyStartBO.setRobotUuid(runApplyPlan.getAppId()); |
|
|
//high 高 middle 中 low 低 |
|
|
//high 高 middle 中 low 低 |
|
|
applyStartBO.setPriority("high"); |
|
|
applyStartBO.setPriority("high"); |
|
|
applyStartBO.setAccountName(listRebotVO.getRobotClientName()); |
|
|
|
|
|
|
|
|
applyStartBO.setAccountName(runRebotList.get(0).getRobotClientName()); |
|
|
// 如果应用支持参数 |
|
|
// 如果应用支持参数 |
|
|
if (!Objects.isNull(applyPlan.getSupportParam()) && applyPlan.getSupportParam() == 1) { |
|
|
|
|
|
List<ResourceLibrary> list = resourceLibraryService.lambdaQuery().eq(ResourceLibrary::getAppId, applyPlan.getAppId()).list(); |
|
|
|
|
|
|
|
|
if (!Objects.isNull(runApplyPlan.getSupportParam()) && runApplyPlan.getSupportParam() == 1) { |
|
|
|
|
|
List<ResourceLibrary> list = resourceLibraryService.lambdaQuery().eq(ResourceLibrary::getAppId, runApplyPlan.getAppId()).list(); |
|
|
if (!list.isEmpty()) { |
|
|
if (!list.isEmpty()) { |
|
|
List<ApplyStartBO.RobotParam> robotParamList = list.stream().map(e -> { |
|
|
List<ApplyStartBO.RobotParam> robotParamList = list.stream().map(e -> { |
|
|
ApplyStartBO.RobotParam robotParam = new ApplyStartBO.RobotParam(); |
|
|
ApplyStartBO.RobotParam robotParam = new ApplyStartBO.RobotParam(); |
|
@@ -655,23 +726,23 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
} |
|
|
} |
|
|
JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); |
|
|
JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); |
|
|
ApplyPlan updateApplyPlan = new ApplyPlan(); |
|
|
ApplyPlan updateApplyPlan = new ApplyPlan(); |
|
|
updateApplyPlan.setId(applyPlan.getId()); |
|
|
|
|
|
|
|
|
updateApplyPlan.setId(runApplyPlan.getId()); |
|
|
updateApplyPlan.setCreateBy("系统创建"); |
|
|
updateApplyPlan.setCreateBy("系统创建"); |
|
|
updateApplyPlan.setCreateTime(new Date()); |
|
|
updateApplyPlan.setCreateTime(new Date()); |
|
|
updateApplyPlan.setUpdateBy("系统修改"); |
|
|
updateApplyPlan.setUpdateBy("系统修改"); |
|
|
updateApplyPlan.setUpdateTime(new Date()); |
|
|
updateApplyPlan.setUpdateTime(new Date()); |
|
|
updateApplyPlan.setStartTime(new Date()); |
|
|
updateApplyPlan.setStartTime(new Date()); |
|
|
updateApplyPlan.setTaskUuid(jobStartVO.getJobUuid()); |
|
|
updateApplyPlan.setTaskUuid(jobStartVO.getJobUuid()); |
|
|
updateApplyPlan.setPlanName(applyPlan.getPlanName()); |
|
|
|
|
|
|
|
|
updateApplyPlan.setPlanName(runApplyPlan.getPlanName()); |
|
|
updateApplyPlan.setTaskStatus(PlanRunStatus.CREATED.getKey()); |
|
|
updateApplyPlan.setTaskStatus(PlanRunStatus.CREATED.getKey()); |
|
|
updateApplyPlan.setRobotName(listRebotVO.getRobotClientName()); |
|
|
|
|
|
updateApplyPlan.setManualTime(applyPlan.getManualTime()); |
|
|
|
|
|
|
|
|
updateApplyPlan.setRobotName(runRebotList.get(0).getRobotClientName()); |
|
|
|
|
|
updateApplyPlan.setManualTime(runApplyPlan.getManualTime()); |
|
|
updateApplyPlan.setDeptId(applyStartBO.getDeptId()); |
|
|
updateApplyPlan.setDeptId(applyStartBO.getDeptId()); |
|
|
updateApplyPlan.setPlanParams(applyStartBO.getPlanParams()); |
|
|
updateApplyPlan.setPlanParams(applyStartBO.getPlanParams()); |
|
|
applyPlan.setTaskUuid(jobStartVO.getJobUuid()); |
|
|
|
|
|
|
|
|
runApplyPlan.setTaskUuid(jobStartVO.getJobUuid()); |
|
|
if (this.saveOrUpdate(updateApplyPlan)) { |
|
|
if (this.saveOrUpdate(updateApplyPlan)) { |
|
|
// 移除当前对象,防止重复跑 |
|
|
|
|
|
applyPlans.remove(0); |
|
|
|
|
|
|
|
|
// 当前机器人已用,移除 |
|
|
|
|
|
runRebotList.remove(0); |
|
|
i++; |
|
|
i++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -689,32 +760,32 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取可执行机器人 |
|
|
* 获取可执行机器人 |
|
|
* @return bool 是否可继续执行 |
|
|
|
|
|
|
|
|
* |
|
|
|
|
|
* @return list 返回可执行的机器人列表 null为无 |
|
|
*/ |
|
|
*/ |
|
|
private List<ListRebotVO> getRunRebot(List<ListRebotVO> listRebotVos){ |
|
|
|
|
|
// 查询应用是否有指定机器人,没有则随机指派 |
|
|
|
|
|
List<String> rebotList = applyRebotService.list(new LambdaQueryWrapper<ApplyRebot>().eq(ApplyRebot::getApplyId, applyStartBO.getRobotUuid())).stream().map(ApplyRebot::getRebotName).collect(Collectors.toList()); |
|
|
|
|
|
// 是否继续执行 |
|
|
|
|
|
List<ListRebotVO> runRebotList = new ArrayList<>(); |
|
|
|
|
|
// 如果查到关系,则该应用指定了机器人 |
|
|
|
|
|
if(!rebotList.isEmpty()){ |
|
|
|
|
|
// 遍历可用机器人 |
|
|
|
|
|
listRebotVos.forEach(e->{ |
|
|
|
|
|
// 如果有指定可用 |
|
|
|
|
|
if(rebotList.contains(e.getRobotClientName())){ |
|
|
|
|
|
runRebotList.add(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}else{ |
|
|
|
|
|
runRebotList.addAll(listRebotVos); |
|
|
|
|
|
} |
|
|
|
|
|
if(runRebotList.isEmpty()){ |
|
|
|
|
|
return runRebotList; |
|
|
|
|
|
}else{ |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<ListRebotVO> getRunRebot(List<ListRebotVO> listRebotVos, String appId) { |
|
|
|
|
|
// 查询应用是否有指定机器人,没有则随机指派 |
|
|
|
|
|
List<String> rebotList = applyRebotService.list(new LambdaQueryWrapper<ApplyRebot>().eq(ApplyRebot::getApplyId, appId)).stream().map(ApplyRebot::getRebotName).collect(Collectors.toList()); |
|
|
|
|
|
// 是否继续执行 |
|
|
|
|
|
List<ListRebotVO> runRebotList = new ArrayList<>(); |
|
|
|
|
|
// 如果查到关系,则该应用指定了机器人 |
|
|
|
|
|
if (!rebotList.isEmpty()) { |
|
|
|
|
|
// 遍历可用机器人 |
|
|
|
|
|
listRebotVos.forEach(e -> { |
|
|
|
|
|
// 如果有指定可用 |
|
|
|
|
|
if (rebotList.contains(e.getRobotClientName())) { |
|
|
|
|
|
runRebotList.add(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
runRebotList.addAll(listRebotVos); |
|
|
|
|
|
} |
|
|
|
|
|
if (!runRebotList.isEmpty()) { |
|
|
|
|
|
return runRebotList; |
|
|
|
|
|
} else { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|